use of com.bvalosek.cpuspy.CpuStateMonitor in project MTweaks-KernelAdiutorMOD by morogoku.
the class OverallFragment method frequenciesInit.
private void frequenciesInit(List<RecyclerViewItem> items) {
FrequencyButtonView frequencyButtonView = new FrequencyButtonView();
frequencyButtonView.setRefreshListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateFrequency();
}
});
frequencyButtonView.setResetListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CpuStateMonitor cpuStateMonitor = mCpuSpyBig.getCpuStateMonitor();
CpuStateMonitor cpuStateMonitorLITTLE = null;
if (mCpuSpyLITTLE != null) {
cpuStateMonitorLITTLE = mCpuSpyLITTLE.getCpuStateMonitor();
}
try {
cpuStateMonitor.setOffsets();
if (cpuStateMonitorLITTLE != null) {
cpuStateMonitorLITTLE.setOffsets();
}
} catch (CpuStateMonitor.CpuStateMonitorException ignored) {
}
mCpuSpyBig.saveOffsets(getActivity());
if (mCpuSpyLITTLE != null) {
mCpuSpyLITTLE.saveOffsets(getActivity());
}
updateView(cpuStateMonitor, mFreqBig);
if (cpuStateMonitorLITTLE != null) {
updateView(cpuStateMonitorLITTLE, mFreqLITTLE);
}
adjustScrollPosition();
}
});
frequencyButtonView.setRestoreListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CpuStateMonitor cpuStateMonitor = mCpuSpyBig.getCpuStateMonitor();
CpuStateMonitor cpuStateMonitorLITTLE = null;
if (mCpuSpyLITTLE != null) {
cpuStateMonitorLITTLE = mCpuSpyLITTLE.getCpuStateMonitor();
}
cpuStateMonitor.removeOffsets();
if (cpuStateMonitorLITTLE != null) {
cpuStateMonitorLITTLE.removeOffsets();
}
mCpuSpyBig.saveOffsets(getActivity());
if (mCpuSpyLITTLE != null) {
mCpuSpyLITTLE.saveOffsets(getActivity());
}
updateView(cpuStateMonitor, mFreqBig);
if (mCpuSpyLITTLE != null) {
updateView(cpuStateMonitorLITTLE, mFreqLITTLE);
}
adjustScrollPosition();
}
});
items.add(frequencyButtonView);
mFreqBig = new CardView(getActivity());
if (CPUFreq.isBigLITTLE()) {
mFreqBig.setTitle(getString(R.string.cluster_big));
} else {
mFreqBig.setFullSpan(true);
}
items.add(mFreqBig);
if (CPUFreq.isBigLITTLE()) {
mFreqLITTLE = new CardView(getActivity());
mFreqLITTLE.setTitle(getString(R.string.cluster_little));
items.add(mFreqLITTLE);
}
mCpuSpyBig = new CpuSpyApp(CPUFreq.getBigCpu(), getActivity());
if (CPUFreq.isBigLITTLE()) {
mCpuSpyLITTLE = new CpuSpyApp(CPUFreq.getLITTLECpu(), getActivity());
}
updateFrequency();
}
use of com.bvalosek.cpuspy.CpuStateMonitor in project MTweaks-KernelAdiutorMOD by morogoku.
the class OverallFragment method updateView.
private void updateView(CpuStateMonitor monitor, CardView card) {
if (!isAdded() || card == null)
return;
card.clearItems();
// update the total state time
DescriptionView totalTime = new DescriptionView();
totalTime.setTitle(getString(R.string.uptime));
totalTime.setSummary(sToString(monitor.getTotalStateTime() / 100L));
card.addItem(totalTime);
/**
* Get the CpuStateMonitor from the app, and iterate over all states,
* creating a row if the duration is > 0 or otherwise marking it in
* extraStates (missing)
*/
List<String> extraStates = new ArrayList<>();
for (CpuStateMonitor.CpuState state : monitor.getStates()) {
if (state.getDuration() > 0) {
generateStateRow(monitor, state, card);
} else {
if (state.getFreq() == 0) {
extraStates.add(getString(R.string.deep_sleep));
} else {
extraStates.add(state.getFreq() / 1000 + getString(R.string.mhz));
}
}
}
if (monitor.getStates().size() == 0) {
card.clearItems();
DescriptionView errorView = new DescriptionView();
errorView.setTitle(getString(R.string.error_frequencies));
card.addItem(errorView);
return;
}
// for all the 0 duration states, add the the Unused State area
if (extraStates.size() > 0) {
int n = 0;
String str = "";
for (String s : extraStates) {
if (n++ > 0)
str += ", ";
str += s;
}
DescriptionView unusedText = new DescriptionView();
unusedText.setTitle(getString(R.string.unused_frequencies));
unusedText.setSummary(str);
card.addItem(unusedText);
}
}
Aggregations