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