OSDN Git Service

[AWARE] Make PeerHandle comparable/hashable
authorEtan Cohen <etancohen@google.com>
Mon, 4 Dec 2017 15:53:31 +0000 (07:53 -0800)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Thu, 8 Feb 2018 04:10:46 +0000 (04:10 +0000)
Add public equals()/hash() methods to PeerHandle. Allows the handle to
be used across multiple calls/sessions.

(partial cherry-pick of commit 3d33d7495ffbf12966299df8359d71a6f0926e7a)
(cherry-pick of commit 0d49c0dda8bfef0267d81e8490e4882e51a15af4)

Bug: 68931709
Test: builds, unit test, integration test
Change-Id: I87df50edb948a7afc90e496165013235ddca1e48
Merged-In: Idc59269d4275181ed6d9a793213c681dc4e98134
Merged-In: I6848acda9bfef306b8feaae6987ff18f7bc2e6ec
(cherry picked from commit 4454bda052aea4087880674bb0e0f81ce2647009)

wifi/java/android/net/wifi/aware/PeerHandle.java

index cd45c52..b525212 100644 (file)
@@ -32,4 +32,22 @@ public class PeerHandle {
 
     /** @hide */
     public int peerId;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof PeerHandle)) {
+            return false;
+        }
+
+        return peerId == ((PeerHandle) o).peerId;
+    }
+
+    @Override
+    public int hashCode() {
+        return peerId;
+    }
 }