From 4e6bd94ed185f35f0333074b6814851008a80103 Mon Sep 17 00:00:00 2001 From: Songchun Fan Date: Thu, 5 May 2022 21:13:03 +0000 Subject: [PATCH] [snapshot] skip onChanged() in Watched* snapshot() During snapshot building we should directly modify mStorage and skip those onChanged() calls in the wrapper classes. BUG: 231373522 Test: builds Change-Id: Idc00332a681d83b9588e564f1ad8303c374a0948 --- .../core/java/com/android/server/utils/WatchedArrayList.java | 2 +- .../core/java/com/android/server/utils/WatchedArrayMap.java | 2 +- .../core/java/com/android/server/utils/WatchedArraySet.java | 2 +- .../java/com/android/server/utils/WatchedLongSparseArray.java | 2 +- .../core/java/com/android/server/utils/WatchedSparseArray.java | 2 +- .../com/android/server/utils/WatchedSparseBooleanArray.java | 2 +- .../java/com/android/server/utils/WatchedSparseIntArray.java | 2 +- .../java/com/android/server/utils/WatchedSparseSetArray.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/utils/WatchedArrayList.java b/services/core/java/com/android/server/utils/WatchedArrayList.java index 75e39ebb32d86..07474a63cb2aa 100644 --- a/services/core/java/com/android/server/utils/WatchedArrayList.java +++ b/services/core/java/com/android/server/utils/WatchedArrayList.java @@ -416,7 +416,7 @@ public class WatchedArrayList extends WatchableImpl dst.mStorage.ensureCapacity(end); for (int i = 0; i < end; i++) { final E val = Snapshots.maybeSnapshot(src.get(i)); - dst.add(val); + dst.mStorage.add(val); } dst.seal(); } diff --git a/services/core/java/com/android/server/utils/WatchedArrayMap.java b/services/core/java/com/android/server/utils/WatchedArrayMap.java index 7c1cde8502bdd..63441aac8e1f5 100644 --- a/services/core/java/com/android/server/utils/WatchedArrayMap.java +++ b/services/core/java/com/android/server/utils/WatchedArrayMap.java @@ -465,7 +465,7 @@ public class WatchedArrayMap extends WatchableImpl for (int i = 0; i < end; i++) { final V val = Snapshots.maybeSnapshot(src.valueAt(i)); final K key = src.keyAt(i); - dst.put(key, val); + dst.mStorage.put(key, val); } dst.seal(); } diff --git a/services/core/java/com/android/server/utils/WatchedArraySet.java b/services/core/java/com/android/server/utils/WatchedArraySet.java index ec80261a2196e..a2eaed72dd651 100644 --- a/services/core/java/com/android/server/utils/WatchedArraySet.java +++ b/services/core/java/com/android/server/utils/WatchedArraySet.java @@ -427,7 +427,7 @@ public class WatchedArraySet extends WatchableImpl dst.mStorage.ensureCapacity(end); for (int i = 0; i < end; i++) { final E val = Snapshots.maybeSnapshot(src.valueAt(i)); - dst.append(val); + dst.mStorage.append(val); } dst.seal(); } diff --git a/services/core/java/com/android/server/utils/WatchedLongSparseArray.java b/services/core/java/com/android/server/utils/WatchedLongSparseArray.java index bf23de12ffef3..9da9e75f98fb2 100644 --- a/services/core/java/com/android/server/utils/WatchedLongSparseArray.java +++ b/services/core/java/com/android/server/utils/WatchedLongSparseArray.java @@ -410,7 +410,7 @@ public class WatchedLongSparseArray extends WatchableImpl for (int i = 0; i < end; i++) { final E val = Snapshots.maybeSnapshot(src.valueAt(i)); final long key = src.keyAt(i); - dst.put(key, val); + dst.mStorage.put(key, val); } dst.seal(); } diff --git a/services/core/java/com/android/server/utils/WatchedSparseArray.java b/services/core/java/com/android/server/utils/WatchedSparseArray.java index 9b99b9176d194..6ce38b71d9cd7 100644 --- a/services/core/java/com/android/server/utils/WatchedSparseArray.java +++ b/services/core/java/com/android/server/utils/WatchedSparseArray.java @@ -490,7 +490,7 @@ public class WatchedSparseArray extends WatchableImpl for (int i = 0; i < end; i++) { final E val = Snapshots.maybeSnapshot(src.valueAt(i)); final int key = src.keyAt(i); - dst.put(key, val); + dst.mStorage.put(key, val); } dst.seal(); } diff --git a/services/core/java/com/android/server/utils/WatchedSparseBooleanArray.java b/services/core/java/com/android/server/utils/WatchedSparseBooleanArray.java index 772a8d07cffb5..50e2272afb728 100644 --- a/services/core/java/com/android/server/utils/WatchedSparseBooleanArray.java +++ b/services/core/java/com/android/server/utils/WatchedSparseBooleanArray.java @@ -310,7 +310,7 @@ public class WatchedSparseBooleanArray extends WatchableImpl } final int end = src.size(); for (int i = 0; i < end; i++) { - dst.put(src.keyAt(i), src.valueAt(i)); + dst.mStorage.put(src.keyAt(i), src.valueAt(i)); } dst.seal(); } diff --git a/services/core/java/com/android/server/utils/WatchedSparseIntArray.java b/services/core/java/com/android/server/utils/WatchedSparseIntArray.java index 72705bf24199b..53d1682451809 100644 --- a/services/core/java/com/android/server/utils/WatchedSparseIntArray.java +++ b/services/core/java/com/android/server/utils/WatchedSparseIntArray.java @@ -315,7 +315,7 @@ public class WatchedSparseIntArray extends WatchableImpl } final int end = src.size(); for (int i = 0; i < end; i++) { - dst.put(src.keyAt(i), src.valueAt(i)); + dst.mStorage.put(src.keyAt(i), src.valueAt(i)); } dst.seal(); } diff --git a/services/core/java/com/android/server/utils/WatchedSparseSetArray.java b/services/core/java/com/android/server/utils/WatchedSparseSetArray.java index 05db12e49a13d..77750ed92273d 100644 --- a/services/core/java/com/android/server/utils/WatchedSparseSetArray.java +++ b/services/core/java/com/android/server/utils/WatchedSparseSetArray.java @@ -169,7 +169,7 @@ public class WatchedSparseSetArray extends WatchableImpl implements Snappable final ArraySet set = src.get(i); final int setSize = set.size(); for (int j = 0; j < setSize; j++) { - dst.add(src.keyAt(i), set.valueAt(j)); + dst.mStorage.add(src.keyAt(i), set.valueAt(j)); } } dst.seal();