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

Commit f17961cd 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 am: 7805396e

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4ef1ab620b8a56e62c295d081f714de208d9fa57
parents 67fb6f51 7805396e
Loading
Loading
Loading
Loading
+19 −13
Original line number Original line Diff line number Diff line
@@ -78,6 +78,8 @@ public class KernelWakelockReader {
        boolean useSystemSuspend = (new File(sSysClassWakeupDir)).exists();
        boolean useSystemSuspend = (new File(sSysClassWakeupDir)).exists();


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


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


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