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 import android.net.wifi.WifiManager; 22 import android.util.Log; 23 24 import com.android.server.wifi.SupplicantStaIfaceHal.SupplicantEventCode; 25 26 /** 27 * Stores supplicant event information passed from WifiMonitor. 28 */ 29 public class SupplicantEventInfo { 30 private static final String TAG = "SupplicantEventInfo"; SupplicantEventInfo(@upplicantEventCode int eventCode, @NonNull MacAddress bssid, @NonNull String reasonString)31 SupplicantEventInfo(@SupplicantEventCode int eventCode, @NonNull MacAddress bssid, 32 @NonNull String reasonString) { 33 if (bssid == null) { 34 Log.wtf(TAG, "Null BSSID provided"); 35 this.bssid = WifiManager.ALL_ZEROS_MAC_ADDRESS; 36 } else { 37 this.bssid = bssid; 38 } 39 if (reasonString == null) { 40 Log.wtf(TAG, "Null reason string provided"); 41 this.reasonString = "unknown"; 42 } else { 43 this.reasonString = reasonString; 44 } 45 this.eventCode = eventCode; 46 } 47 public final @SupplicantEventCode int eventCode; 48 @NonNull public final MacAddress bssid; 49 @NonNull public final String reasonString; 50 51 @Override toString()52 public String toString() { 53 StringBuilder sb = new StringBuilder(); 54 sb.append(" eventCode: ").append(SupplicantStaIfaceHal 55 .supplicantEventCodeToString(eventCode)); 56 sb.append(" bssid: ").append(bssid); 57 sb.append(" reasonString: ").append(reasonString); 58 return sb.toString(); 59 } 60 } 61