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

Commit a8f414fd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix FileObserver memory leak, If an application use FileObserver...

Merge "Fix FileObserver memory leak, If an application use FileObserver funtion startWatching some files, then stopWatching, WeakReference will leak in mRealObservers container." into main
parents 6c4d7953 5522a0eb
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public abstract class FileObserver {
    private static class ObserverThread extends Thread {
        /** Temporarily retained; appears to be missing UnsupportedAppUsage annotation */
        private HashMap<Integer, WeakReference> m_observers = new HashMap<Integer, WeakReference>();
        private SparseArray<WeakReference> mRealObservers = new SparseArray<>();
        private final SparseArray<WeakReference> mRealObservers = new SparseArray<>();
        private int m_fd;

        public ObserverThread() {
@@ -143,6 +143,11 @@ public abstract class FileObserver {

        public void stopWatching(int[] descriptors) {
            stopWatching(m_fd, descriptors);
            synchronized (mRealObservers) {
                for (int wfd: descriptors) {
                    mRealObservers.delete(wfd);
                }
            }
        }

        @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)