Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9f60a53 authored by Benjamin Schwartz's avatar Benjamin Schwartz Committed by Gerrit Code Review
Browse files

Merge "KernelWakelockReader: provide class level lock when updates staleStats"

parents b8b8a392 5886ede6
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ public class KernelWakelockReader {
        boolean useSystemSuspend = (new File(sSysClassWakeupDir)).exists();

        if (useSystemSuspend) {
            // static read/write lock protection for sKernelWakelockUpdateVersion
            synchronized (KernelWakelockReader.class) {
                // Get both kernel and native wakelock stats from SystemSuspend
                updateVersion(staleStats);
                if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
@@ -85,6 +87,7 @@ public class KernelWakelockReader {
                    return null;
                }
                return removeOldStats(staleStats);
            }
        } else {
            Arrays.fill(mKernelWakelockBuffer, (byte) 0);
            int len = 0;
@@ -141,6 +144,8 @@ public class KernelWakelockReader {
                }
            }

            // static read/write lock protection for sKernelWakelockUpdateVersion
            synchronized (KernelWakelockReader.class) {
                updateVersion(staleStats);
                // Get native wakelock stats from SystemSuspend
                if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
@@ -151,6 +156,7 @@ public class KernelWakelockReader {
                return removeOldStats(staleStats);
            }
        }
    }

    /**
     * Attempt to wait for suspend_control service if not immediately available.