1 /*
2  * Copyright (C) 2020 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 package com.android.server.wifi;
17 
18 import android.annotation.NonNull;
19 import android.net.wifi.WifiManager;
20 import android.util.Log;
21 
22 /**
23  * Stores disconnect information passed from WifiMonitor.
24  */
25 public class DisconnectEventInfo {
26     @NonNull public final String ssid;
27     @NonNull public final String bssid;
28     public final int reasonCode;
29     public final boolean locallyGenerated;
30 
31     private static final String TAG = "DisconnectEventInfo";
32 
DisconnectEventInfo(@onNull String ssid, @NonNull String bssid, int reasonCode, boolean locallyGenerated)33     public DisconnectEventInfo(@NonNull String ssid, @NonNull String bssid, int reasonCode,
34             boolean locallyGenerated) {
35         if (ssid == null) {
36             Log.wtf(TAG, "Null SSID provided");
37             this.ssid = WifiManager.UNKNOWN_SSID;
38         } else {
39             this.ssid = ssid;
40         }
41         if (bssid == null) {
42             Log.wtf(TAG, "Null BSSID provided");
43             this.bssid = WifiManager.ALL_ZEROS_MAC_ADDRESS.toString();
44         } else {
45             this.bssid = bssid;
46         }
47         this.reasonCode = reasonCode;
48         this.locallyGenerated = locallyGenerated;
49     }
50 
51     @Override
toString()52     public String toString() {
53         StringBuffer sb = new StringBuffer();
54         sb.append(" ssid: ").append(ssid);
55         sb.append(" bssid: ").append(bssid);
56         sb.append(" reasonCode: ").append(reasonCode);
57         sb.append(" locallyGenerated: ").append(locallyGenerated);
58         return sb.toString();
59     }
60 }
61