diff options
| author | Songchun Fan <schfan@google.com> | 2022-04-01 16:42:38 +0000 |
|---|---|---|
| committer | Songchun Fan <schfan@google.com> | 2022-04-06 20:53:31 +0000 |
| commit | 3def2802db726dc078a5e359b71aa814293aee04 (patch) | |
| tree | bf1bedb16806d384ba0c7b0931ccca5e870c5ea4 /core/java/android/util/SparseSetArray.java | |
| parent | aea49e77fdefa2295758ac23f971c39b98548511 (diff) | |
Revert "Revert "[AppsFilter] read-only interface for snapshots""
This reverts commit 2e06c6008e595b9b167f3463431d9dcdb16687bb.
Reason for revert: fixing the boot time regression
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.
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: I06624ea79ff85160488a6c7863213b0c44fe2154
Diffstat (limited to 'core/java/android/util/SparseSetArray.java')
| -rw-r--r-- | core/java/android/util/SparseSetArray.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/util/SparseSetArray.java b/core/java/android/util/SparseSetArray.java index f5025f7a9e99..f85280f0264b 100644 --- a/core/java/android/util/SparseSetArray.java +++ b/core/java/android/util/SparseSetArray.java @@ -15,15 +15,34 @@ */ package android.util; +import android.annotation.NonNull; + /** * A sparse array of ArraySets, which is suitable to hold userid->packages association. * * @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(@NonNull 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)); + } + } } /** |
