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

Commit ed9c88c9 authored by Ahmad Khalil's avatar Ahmad Khalil Committed by Automerger Merge Worker
Browse files

Merge "VibrationSettings: add synchronized control for access of...

Merge "VibrationSettings: add synchronized control for access of mProcStatesCache" into main am: 266f845d am: 190201f6

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



Change-Id: Ie380c88bf63c9ea74b093fe0736caf921c2eaf5f
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents dedafbf4 190201f6
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -731,20 +731,26 @@ final class VibrationSettings {
        private final SparseArray<Integer> mProcStatesCache = new SparseArray<>();

        public boolean isUidForeground(int uid) {
            synchronized (this) {
                return mProcStatesCache.get(uid, ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND)
                        <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
            }
        }

        @Override
        public void onUidGone(int uid, boolean disabled) {
            synchronized (this) {
                mProcStatesCache.delete(uid);
            }
        }

        @Override
        public void onUidStateChanged(int uid, int procState, long procStateSeq, int capability) {
            synchronized (this) {
                mProcStatesCache.put(uid, procState);
            }
        }
    }

    /**
     * Implementation of Virtual Device listeners for the changes of virtual displays and of apps