Java Code Examples for com.grarak.kerneladiutor.utils.Utils#strFormat()
The following examples show how to use
com.grarak.kerneladiutor.utils.Utils#strFormat() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoreCtl.java From KernelAdiutor with GNU General Public License v3.0 | 6 votes |
private CoreCtl() { String parent = null; for (String file : sFiles) { if (Utils.existFile(Utils.strFormat(file, 0))) { parent = file; break; } } if (parent != null) { if (Utils.existFile(Utils.strFormat(parent, CPUFreq.getInstance().getBigCpu()))) { PARENT = Utils.strFormat(parent, CPUFreq.getInstance().getBigCpu()); if (Utils.existFile(PARENT + IS_BIG_CLUSTER)) { PARENT = Utils.readFile(PARENT + IS_BIG_CLUSTER).equals("1") ? PARENT : null; } } } }
Example 2
Source File: CpuStateMonitor.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
/** * list of all the CPU frequency states, which contains both a * frequency and a duration (time spent in that state */ public void updateStates() throws CpuStateMonitorException { CPUFreq cpuFreq = CPUFreq.getInstance(); mStates.clear(); try { String file; if (Utils.existFile(Utils.strFormat(CPUFreq.TIME_STATE, mCore))) { file = Utils.strFormat(CPUFreq.TIME_STATE, mCore); } else { file = Utils.strFormat(CPUFreq.TIME_STATE_2, mCore); } boolean offline = cpuFreq.isOffline(mCore); if (offline) { cpuFreq.onlineCpu(mCore, true, false, null); } String states = Utils.readFile(file); if (offline) { cpuFreq.onlineCpu(mCore, false, false, null); } if (states.isEmpty()) { throw new CpuStateMonitorException("Problem opening time-in-states file"); } readInStates(states.split("\\r?\\n")); } catch (Exception e) { throw new CpuStateMonitorException("Problem opening time-in-states file"); } /* * deep sleep time determined by difference between elapsed (total) boot * time and the system uptime (awake) */ long sleepTime = (SystemClock.elapsedRealtime() - SystemClock.uptimeMillis()) / 10; mStates.add(new CpuState(0, sleepTime)); Collections.sort(mStates, Collections.reverseOrder()); }
Example 3
Source File: PathReaderFragment.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
@Override protected void load(List<RecyclerViewItem> items) { super.load(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(item -> { List<Integer> freqs = CPUFreq.getInstance(getActivity()).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); } } }
Example 4
Source File: CPUFreq.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
public String getGovernorTunablesPath(int cpu, String governor) { if (Utils.existFile(Utils.strFormat(CPU_GOVERNOR_TUNABLES_CORE, cpu, governor))) { return CPU_GOVERNOR_TUNABLES_CORE.replace("%s", governor); } else { return Utils.strFormat(CPU_GOVERNOR_TUNABLES, governor); } }
Example 5
Source File: GPUFreq.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
public String getTunables(String governor) { return Utils.strFormat(TUNABLES, governor); }
Example 6
Source File: ApplyOnBoot.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
private static List<String> getApplyCpu(CPUFreq.ApplyCpu applyCpu, RootUtils.SU su, Context context) { List<String> commands = new ArrayList<>(); boolean cpulock = Utils.existFile(CPUFreq.CPU_LOCK_FREQ, su); if (cpulock) { commands.add(Control.write("0", CPUFreq.CPU_LOCK_FREQ)); } boolean mpdecision = Utils.hasProp(MPDecision.HOTPLUG_MPDEC, su) && Utils.isPropRunning(MPDecision.HOTPLUG_MPDEC, su); if (mpdecision) { commands.add(Control.stopService(MPDecision.HOTPLUG_MPDEC)); } for (int i = applyCpu.getMin(); i <= applyCpu.getMax(); i++) { boolean offline = !Utils.existFile(Utils.strFormat(applyCpu.getPath(), i), su); List<Integer> bigCpuRange = applyCpu.getBigCpuRange(); List<Integer> LITTLECpuRange = applyCpu.getLITTLECpuRange(); String coreCtlMinPath = null; String msmPerformanceMinPath = null; if (offline) { if (applyCpu.isBigLITTLE()) { if (Utils.existFile(Utils.strFormat(CoreCtl.CORE_CTL, i), su)) { coreCtlMinPath = Utils.strFormat(CoreCtl.CORE_CTL + CoreCtl.MIN_CPUS, i); commands.add(Control.write(String.valueOf(bigCpuRange.size()), coreCtlMinPath)); } if (Utils.existFile(MSMPerformance.MAX_CPUS, su)) { msmPerformanceMinPath = MSMPerformance.MAX_CPUS; commands.add(Control.write(LITTLECpuRange.size() + ":" + bigCpuRange.size(), msmPerformanceMinPath)); } } commands.add(Control.write("1", Utils.strFormat(CPUFreq.CPU_ONLINE, i))); } commands.add(Control.chmod("644", Utils.strFormat(applyCpu.getPath(), i))); commands.add(Control.write(applyCpu.getValue(), Utils.strFormat(applyCpu.getPath(), i))); commands.add(Control.chmod("444", Utils.strFormat(applyCpu.getPath(), i))); if (offline) { if (coreCtlMinPath != null) { commands.add(Control.write(String.valueOf(context == null ? CPUFreq.getInstance().mCoreCtlMinCpu : AppSettings.getCoreCtlMinCpusBig(context)), coreCtlMinPath)); } if (msmPerformanceMinPath != null) { commands.add(Control.write("-1:-1", msmPerformanceMinPath)); } commands.add(Control.write("0", Utils.strFormat(CPUFreq.CPU_ONLINE, i))); } } if (mpdecision) { commands.add(Control.startService(MPDecision.HOTPLUG_MPDEC)); } if (cpulock) { commands.add(Control.write("1", CPUFreq.CPU_LOCK_FREQ)); } return commands; }