private View generateStateRow_big(CpuStateMonitor.CpuState state, ViewGroup parent) { // inflate the XML into a view in the parent LayoutInflater inf = LayoutInflater.from(getActivity()); LinearLayout theRow = (LinearLayout) inf.inflate(R.layout.state_row, parent, false); // what percetnage we've got CpuStateMonitor monitor = _app.getCpuStateMonitor(); float per = (float) state.duration * 100 / monitor.getTotalStateTime_big(); // state name String sFreq; if (state.freq == 0) { sFreq = getString(R.string.deep_sleep); } else { sFreq = state.freq / 1000 + " MHz"; } // duration long tSec = state.duration / 100; String sDur = sToString(tSec); TextView freqText = (TextView) theRow.findViewById(R.id.ui_freq_text); TextView durText = (TextView) theRow.findViewById(R.id.ui_duration_text); CircleChart perText = (CircleChart) theRow.findViewById(R.id.ui_percentage_text); // modify the row freqText.setText(sFreq); perText.setMax(100); perText.setProgress((int) per); durText.setText(sDur); // add it to parent and return parent.addView(theRow); return theRow; }
/** Stuff to do on a seperate thread */ @Override protected Void doInBackground(Void... v) { CpuStateMonitor monitor = _app.getCpuStateMonitor(); try { monitor.updateStates(); if (CPU.isBigCluster()) monitor.updateStates_Big(); } catch (CpuStateMonitor.CpuStateMonitorException e) { Log.e(TAG, "Problem getting CPU states"); } return null; }
public void updateView_big() { /** * 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) */ CpuStateMonitor monitor = _app.getCpuStateMonitor(); _uiStatesView_big.removeAllViews(); List<String> extraStates = new ArrayList<>(); for (CpuStateMonitor.CpuState state : monitor.getStates_big()) { if (state.duration > 0) { generateStateRow_big(state, _uiStatesView_big); } else { if (state.freq == 0) { extraStates.add(getString(R.string.deep_sleep)); } else { extraStates.add(state.freq / 1000 + " MHz"); } } } // show the red warning label if no states found if (monitor.getStates().size() == 0) { _uiHeaderTotalStateTime_big.setVisibility(View.GONE); _uiTotalStateTime_big.setVisibility(View.GONE); _uiStatesView_big.setVisibility(View.GONE); } // update the total state time long totTime = monitor.getTotalStateTime_big() / 100; _uiTotalStateTime_big.setText(sToString(totTime)); // 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; } _uiAdditionalStates_big.setVisibility(View.VISIBLE); _uiHeaderAdditionalStates_big.setVisibility(View.VISIBLE); _uiAdditionalStates_big.setText(str); } else { _uiAdditionalStates_big.setVisibility(View.GONE); _uiHeaderAdditionalStates_big.setVisibility(View.GONE); } }