summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2017-01-26 13:14:14 -0500
committerChris Wren <cwren@android.com>2017-01-27 08:28:45 -0500
commit58047b9451d824dd377980976132d9296ff8aaa5 (patch)
tree7b6f31ab1d5e729337589d1e23a11ce3558b3120 /core/java
parent22a7c7ddf2a72f779f60ef0427a7495b566bfaea (diff)
add a comparator for LogMaker
Tests need to be able to compare partial log structures. Bug: 34705522 Test: runtest --path frameworks/base/core/tests/coretests/src/android/metrics Change-Id: I4e26e43f5f5ea3fbba5a2a2a9563982c7260671b
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/metrics/LogMaker.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/java/android/metrics/LogMaker.java b/core/java/android/metrics/LogMaker.java
index 83f30bee4434..0ee25744488c 100644
--- a/core/java/android/metrics/LogMaker.java
+++ b/core/java/android/metrics/LogMaker.java
@@ -240,6 +240,9 @@ public class LogMaker {
return out;
}
+ /**
+ * Reconstitute an object from the output of {@link #serialize()}.
+ */
public void deserialize(Object[] items) {
int i = 0;
while (i < items.length) {
@@ -252,4 +255,22 @@ public class LogMaker {
}
}
}
+
+ /**
+ * @param that the object to compare to.
+ * @return true if values in that equal values in this, for tags that exist in this.
+ */
+ public boolean isSubsetOf(LogMaker that) {
+ if (that == null) {
+ return false;
+ }
+ for (int i = 0; i < entries.size(); i++) {
+ int key = this.entries.keyAt(i);
+ Object thisValue = this.entries.valueAt(i);
+ Object thatValue = that.entries.get(key);
+ if ((thisValue == null && thatValue != null) || !thisValue.equals(thatValue))
+ return false;
+ }
+ return true;
+ }
}