dgets / CPURecord

Just an idea that I had after a few months of noticing every time I'd turn my phone's display back on, the CPU would be pegged. I'm not sure, but I think that it might be indicative of some malware, and I want to collect some other statistics regarding what is going on when the display is inactive.
0 stars 0 forks source link

Final core is a no-go? #4

Closed dgets closed 6 years ago

dgets commented 6 years ago

For some reason, when trying to process the information for the final core, all values are returned as 0, or NaN, by the time it is displayed. Perhaps the problem is that this phone is actually bears one of those weird processors with an odd number of cores? I doubt that's it, so there is probably a logic error somewhere causing the wrong data to be polled. A one-off error...

Code where the error appears follows:

        for (int cntr2 = 0; cntr2 < 4; cntr2++) {
            idle = deviceStats[cntr2][0]; iowait = deviceStats[cntr2][1];
            irq = deviceStats[cntr2][2]; softirq = deviceStats[cntr2][3];

            /*for (int statline : deviceStats[cntr2]) {
                idle = statline[0];
                iowait = statline[1];
                irq = statline[2];
                softirq = statline[3];*/

                total = (idle + iowait + irq + softirq) / 100;  //percentage work
                if (debugging >= GENERAL) {
                    Toast.makeText(appShit, "total: " + total +
                            "\nidle: " + idle + "\niowait: " + iowait +
                            "\nirq: " + irq + "\nsoftirq: " + softirq,
                            Toast.LENGTH_SHORT).show();
                }

                try {
                    statsBox.append("\nCore: " + cntr2 + "\n\tIdle: " +
                            ((float)idle / total) + "%\tIO Wait: " + ((float)iowait / total));
                    statsBox.append("%\n\tIRQ: " + ((float)irq / total) + "%\t\tSoft IRQ: " +
                            ((float)softirq / total) + "%\n\n");
                } catch (Exception e) {
                    Toast.makeText(appShit, "cntr: " + cntr2 + ": " + e.getMessage(), Toast.LENGTH_SHORT).show();
                }
            //}
        }

Told ya that code got uglified...