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

Commit 7805396e authored by Benjamin Schwartz's avatar Benjamin Schwartz Committed by Automerger Merge Worker
Browse files

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

Merge "KernelWakelockReader: provide class level lock when updates staleStats" am: b9f60a53 am: ec137273

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1534034

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I32722ae3a7f5fbde2aa7d42402f8f2d670423f4b
parents 737529ea ec137273
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.