Search in sources :

Example 1 with CpuStateMonitor

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();
}
Also used : FrequencyButtonView(com.moro.mtweaks.views.recyclerview.overallstatistics.FrequencyButtonView) CpuStateMonitor(com.bvalosek.cpuspy.CpuStateMonitor) CpuSpyApp(com.bvalosek.cpuspy.CpuSpyApp) CardView(com.moro.mtweaks.views.recyclerview.CardView) CardView(com.moro.mtweaks.views.recyclerview.CardView) View(android.view.View) TemperatureView(com.moro.mtweaks.views.recyclerview.overallstatistics.TemperatureView) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) StatsView(com.moro.mtweaks.views.recyclerview.StatsView) FrequencyButtonView(com.moro.mtweaks.views.recyclerview.overallstatistics.FrequencyButtonView) TextView(android.widget.TextView) FrequencyTableView(com.moro.mtweaks.views.recyclerview.overallstatistics.FrequencyTableView)

Example 2 with CpuStateMonitor

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);
    }
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) CpuStateMonitor(com.bvalosek.cpuspy.CpuStateMonitor) ArrayList(java.util.ArrayList)

Aggregations

CpuStateMonitor (com.bvalosek.cpuspy.CpuStateMonitor)2 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)2 View (android.view.View)1 TextView (android.widget.TextView)1 CpuSpyApp (com.bvalosek.cpuspy.CpuSpyApp)1 CardView (com.moro.mtweaks.views.recyclerview.CardView)1 StatsView (com.moro.mtweaks.views.recyclerview.StatsView)1 FrequencyButtonView (com.moro.mtweaks.views.recyclerview.overallstatistics.FrequencyButtonView)1 FrequencyTableView (com.moro.mtweaks.views.recyclerview.overallstatistics.FrequencyTableView)1 TemperatureView (com.moro.mtweaks.views.recyclerview.overallstatistics.TemperatureView)1 ArrayList (java.util.ArrayList)1