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