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.nl80211;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 import java.util.Arrays;
23 
24 /**
25  * HiddenNetwork for wificond
26  *
27  * @hide
28  */
29 public class HiddenNetwork implements Parcelable {
30     private static final String TAG = "HiddenNetwork";
31 
32     public byte[] ssid;
33 
34     /** public constructor */
HiddenNetwork()35     public HiddenNetwork() { }
36 
37     /** override comparator */
38     @Override
equals(Object rhs)39     public boolean equals(Object rhs) {
40         if (this == rhs) return true;
41         if (!(rhs instanceof HiddenNetwork)) {
42             return false;
43         }
44         HiddenNetwork network = (HiddenNetwork) rhs;
45         return Arrays.equals(ssid, network.ssid);
46     }
47 
48     /** override hash code */
49     @Override
hashCode()50     public int hashCode() {
51         return Arrays.hashCode(ssid);
52     }
53 
54     /** implement Parcelable interface */
55     @Override
describeContents()56     public int describeContents() {
57         return 0;
58     }
59 
60     /**
61      * implement Parcelable interface
62      * |flags| is ignored.
63      */
64     @Override
writeToParcel(Parcel out, int flags)65     public void writeToParcel(Parcel out, int flags) {
66         out.writeByteArray(ssid);
67     }
68 
69     /** implement Parcelable interface */
70     public static final Parcelable.Creator<HiddenNetwork> CREATOR =
71             new Parcelable.Creator<HiddenNetwork>() {
72         /**
73          * Caller is responsible for providing a valid parcel.
74          */
75         @Override
76         public HiddenNetwork createFromParcel(Parcel in) {
77             HiddenNetwork result = new HiddenNetwork();
78             result.ssid = in.createByteArray();
79             return result;
80         }
81 
82         @Override
83         public HiddenNetwork[] newArray(int size) {
84             return new HiddenNetwork[size];
85         }
86     };
87 }
88