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 17 package com.android.server.wifi; 18 19 import android.annotation.NonNull; 20 import android.hardware.wifi.supplicant.V1_4.ISupplicantStaIfaceCallback.AssociationRejectionData; 21 22 import com.android.server.wifi.util.NativeUtil; 23 24 import java.util.Objects; 25 26 /** 27 * Stores assoc reject information passed from WifiMonitor. 28 */ 29 public class AssocRejectEventInfo { 30 @NonNull public final String ssid; 31 @NonNull public final String bssid; 32 public final int statusCode; 33 public final boolean timedOut; 34 public final MboOceController.OceRssiBasedAssocRejectAttr oceRssiBasedAssocRejectInfo; 35 public final MboOceController.MboAssocDisallowedAttr mboAssocDisallowedInfo; 36 AssocRejectEventInfo(@onNull String ssid, @NonNull String bssid, int statusCode, boolean timedOut)37 public AssocRejectEventInfo(@NonNull String ssid, @NonNull String bssid, int statusCode, 38 boolean timedOut) { 39 this.ssid = Objects.requireNonNull(ssid); 40 this.bssid = Objects.requireNonNull(bssid); 41 this.statusCode = statusCode; 42 this.timedOut = timedOut; 43 this.oceRssiBasedAssocRejectInfo = null; 44 this.mboAssocDisallowedInfo = null; 45 } 46 AssocRejectEventInfo(AssociationRejectionData assocRejectData)47 public AssocRejectEventInfo(AssociationRejectionData assocRejectData) { 48 String ssid = NativeUtil.encodeSsid(assocRejectData.ssid); 49 String bssid = NativeUtil.macAddressFromByteArray(assocRejectData.bssid); 50 this.ssid = Objects.requireNonNull(ssid); 51 this.bssid = Objects.requireNonNull(bssid); 52 this.statusCode = assocRejectData.statusCode; 53 this.timedOut = assocRejectData.timedOut; 54 if (assocRejectData.isMboAssocDisallowedReasonCodePresent) { 55 this.mboAssocDisallowedInfo = new MboOceController.MboAssocDisallowedAttr( 56 assocRejectData.mboAssocDisallowedReason); 57 } else { 58 this.mboAssocDisallowedInfo = null; 59 } 60 if (assocRejectData.isOceRssiBasedAssocRejectAttrPresent) { 61 this.oceRssiBasedAssocRejectInfo = 62 new MboOceController.OceRssiBasedAssocRejectAttr( 63 assocRejectData.oceRssiBasedAssocRejectData.deltaRssi, 64 assocRejectData.oceRssiBasedAssocRejectData.retryDelayS); 65 } else { 66 this.oceRssiBasedAssocRejectInfo = null; 67 } 68 } 69 70 @Override toString()71 public String toString() { 72 StringBuffer sb = new StringBuffer(); 73 sb.append(" ssid: ").append(ssid); 74 sb.append(" bssid: ").append(bssid); 75 sb.append(" statusCode: ").append(statusCode); 76 sb.append(" timedOut: ").append(timedOut); 77 sb.append(" oceRssiBasedAssocRejectInfo: ").append(oceRssiBasedAssocRejectInfo); 78 sb.append(" mboAssocDisallowedInfo: ").append(mboAssocDisallowedInfo); 79 80 return sb.toString(); 81 } 82 } 83