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