• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.net.wifi.aware;
18 
19 /**
20  * Opaque object used to represent a Wi-Fi Aware peer. Obtained from discovery sessions in
21  * {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[], java.util.List)} or
22  * received messages in {@link DiscoverySessionCallback#onMessageReceived(PeerHandle, byte[])}, and
23  * used when sending messages e,g, {@link DiscoverySession#sendMessage(PeerHandle, int, byte[])},
24  * or when configuring a network link to a peer, e.g.
25  * {@link DiscoverySession#createNetworkSpecifierOpen(PeerHandle)} or
26  * {@link DiscoverySession#createNetworkSpecifierPassphrase(PeerHandle, String)}.
27  * <p>
28  * Note that while a {@code PeerHandle} can be used to track a particular peer (i.e. you can compare
29  * the values received from subsequent messages) - it is good practice not to rely on it. Instead
30  * use an application level peer identifier encoded in the message,
31  * {@link DiscoverySession#sendMessage(PeerHandle, int, byte[])}, and/or in the Publish
32  * configuration's service-specific information field,
33  * {@link PublishConfig.Builder#setServiceSpecificInfo(byte[])}, or match filter,
34  * {@link PublishConfig.Builder#setMatchFilter(java.util.List)}.
35  * <p>A parcelable handle object is available with {@link ParcelablePeerHandle}.
36  */
37 public class PeerHandle {
38     /** @hide */
PeerHandle(int peerId)39     public PeerHandle(int peerId) {
40         this.peerId = peerId;
41     }
42 
43     /** @hide */
44     public int peerId;
45 
46     @Override
equals(Object o)47     public boolean equals(Object o) {
48         if (this == o) {
49             return true;
50         }
51 
52         if (!(o instanceof PeerHandle)) {
53             return false;
54         }
55 
56         return peerId == ((PeerHandle) o).peerId;
57     }
58 
59     @Override
hashCode()60     public int hashCode() {
61         return peerId;
62     }
63 }
64