OSDN Git Service

Do not compare ID when deduplicating SecurityEvent
authorRubin Xu <rubinxu@google.com>
Wed, 15 May 2019 16:39:46 +0000 (17:39 +0100)
committerRubin Xu <rubinxu@google.com>
Wed, 15 May 2019 16:39:46 +0000 (17:39 +0100)
Two SecurityEvents should be considered identical as long as
their event content equals, disregarding the id field.

Test: manual
Change-Id: I811f9a104ed3a0d9e02991aeb9e3653c5c02efc3
Fix: 132367517

core/java/android/app/admin/SecurityLog.java
services/devicepolicy/java/com/android/server/devicepolicy/SecurityLogMonitor.java

index 19f4335..9727621 100644 (file)
@@ -636,6 +636,11 @@ public class SecurityLog {
         public int hashCode() {
             return Objects.hash(mEvent, mId);
         }
+
+        /** @hide */
+        public boolean eventEquals(SecurityEvent other) {
+            return other != null && mEvent.equals(other.mEvent);
+        }
     }
     /**
      * Retrieve all security logs and return immediately.
index fb34913..1ab3b98 100644 (file)
@@ -349,7 +349,7 @@ class SecurityLogMonitor implements Runnable {
                 lastPos++;
             } else {
                 // Two events have the same timestamp, check if they are the same.
-                if (lastEvent.equals(curEvent)) {
+                if (lastEvent.eventEquals(curEvent)) {
                     // Actual overlap, just skip the event.
                     if (DEBUG) Slog.d(TAG, "Skipped dup event with timestamp: " + lastNanos);
                 } else {