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

Commit 8cb3e6aa authored by Songchun Fan's avatar Songchun Fan
Browse files

[AppsFilter] read-only interface for snapshots

Provides a read-only interface that is used by computer and snapshots.
It fixes the data conflicts when AppsFilter is changed while a snapshot is
taken. This requires a watchable class for SparseSetArray.

Test: atest AppsFilterTest
Test: atest com.android.server.utils.WatcherTest
Test: m RUN_ERROR_PRONE=true framework services.core |& grep AppsFilter
BUG: 218411030
Change-Id: Ib9d13537b6cec911b2a189aea828e9baec650585
parent 95387ac8
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -21,9 +21,26 @@ package android.util;
 * @hide
 */
public class SparseSetArray<T> {
    private final SparseArray<ArraySet<T>> mData = new SparseArray<>();
    private final SparseArray<ArraySet<T>> mData;

    public SparseSetArray() {
        mData = new SparseArray<>();
    }

    /**
     * Copy constructor
     */
    public SparseSetArray(SparseSetArray<T> src) {
        final int arraySize = src.size();
        mData = new SparseArray<>(arraySize);
        for (int i = 0; i < arraySize; i++) {
            final int key = src.keyAt(i);
            final ArraySet<T> set = src.get(key);
            final int setSize = set.size();
            for (int j = 0; j < setSize; j++) {
                add(key, set.valueAt(j));
            }
        }
    }

    /**
Loading