1 /* 2 * Copyright (C) 2022 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; 18 19 import android.annotation.NonNull; 20 import android.net.MacAddress; 21 22 import java.util.Objects; 23 24 /** 25 * Store authentication failure information passed from WifiMonitor. 26 */ 27 public class AuthenticationFailureEventInfo { 28 @NonNull public final String ssid; 29 @NonNull public final MacAddress bssid; 30 public final int reasonCode; 31 public final int errorCode; 32 AuthenticationFailureEventInfo(@onNull String ssid, @NonNull MacAddress bssid, int reasonCode, int errorCode)33 public AuthenticationFailureEventInfo(@NonNull String ssid, @NonNull MacAddress bssid, 34 int reasonCode, int errorCode) { 35 this.ssid = ssid; 36 this.bssid = bssid; 37 this.reasonCode = reasonCode; 38 this.errorCode = errorCode; 39 } 40 41 @Override toString()42 public String toString() { 43 StringBuilder sb = new StringBuilder(); 44 sb.append(" ssid: ").append(ssid); 45 sb.append(" bssid: ").append(bssid); 46 sb.append(" reasonCode: ").append(reasonCode); 47 sb.append(" errorCode: ").append(errorCode); 48 return sb.toString(); 49 } 50 51 @Override hashCode()52 public int hashCode() { 53 return Objects.hash(ssid, bssid, reasonCode, errorCode); 54 } 55 56 @Override equals(Object that)57 public boolean equals(Object that) { 58 if (this == that) return true; 59 if (!(that instanceof AuthenticationFailureEventInfo)) return false; 60 61 AuthenticationFailureEventInfo thatAuthenticationFailureEventInfo = 62 (AuthenticationFailureEventInfo) that; 63 return (reasonCode == thatAuthenticationFailureEventInfo.reasonCode 64 && errorCode == thatAuthenticationFailureEventInfo.errorCode 65 && Objects.equals(ssid, thatAuthenticationFailureEventInfo.ssid) 66 && Objects.equals(bssid, thatAuthenticationFailureEventInfo.bssid)); 67 } 68 } 69