• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.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(android.hardware.wifi.supplicant.V1_4 .ISupplicantStaIfaceCallback.AssociationRejectionData assocRejectData)47     public AssocRejectEventInfo(android.hardware.wifi.supplicant.V1_4
48             .ISupplicantStaIfaceCallback.AssociationRejectionData assocRejectData) {
49         String ssid = NativeUtil.encodeSsid(assocRejectData.ssid);
50         String bssid = NativeUtil.macAddressFromByteArray(assocRejectData.bssid);
51         this.ssid = Objects.requireNonNull(ssid);
52         this.bssid = Objects.requireNonNull(bssid);
53         this.statusCode = assocRejectData.statusCode;
54         this.timedOut = assocRejectData.timedOut;
55         if (assocRejectData.isMboAssocDisallowedReasonCodePresent) {
56             this.mboAssocDisallowedInfo = new MboOceController.MboAssocDisallowedAttr(
57                     assocRejectData.mboAssocDisallowedReason);
58         } else {
59             this.mboAssocDisallowedInfo = null;
60         }
61         if (assocRejectData.isOceRssiBasedAssocRejectAttrPresent) {
62             this.oceRssiBasedAssocRejectInfo =
63                     new MboOceController.OceRssiBasedAssocRejectAttr(
64                             assocRejectData.oceRssiBasedAssocRejectData.deltaRssi,
65                             assocRejectData.oceRssiBasedAssocRejectData.retryDelayS);
66         } else {
67             this.oceRssiBasedAssocRejectInfo = null;
68         }
69     }
70 
71     // Constructor using the AIDL definition
AssocRejectEventInfo(AssociationRejectionData assocRejectData)72     public AssocRejectEventInfo(AssociationRejectionData assocRejectData) {
73         String ssid = NativeUtil.encodeSsid(
74                 NativeUtil.byteArrayToArrayList(assocRejectData.ssid));
75         String bssid = NativeUtil.macAddressFromByteArray(assocRejectData.bssid);
76         this.ssid = Objects.requireNonNull(ssid);
77         this.bssid = Objects.requireNonNull(bssid);
78         this.statusCode = assocRejectData.statusCode;
79         this.timedOut = assocRejectData.timedOut;
80         if (assocRejectData.isMboAssocDisallowedReasonCodePresent) {
81             this.mboAssocDisallowedInfo = new MboOceController.MboAssocDisallowedAttr(
82                     assocRejectData.mboAssocDisallowedReason);
83         } else {
84             this.mboAssocDisallowedInfo = null;
85         }
86         if (assocRejectData.isOceRssiBasedAssocRejectAttrPresent) {
87             this.oceRssiBasedAssocRejectInfo =
88                     new MboOceController.OceRssiBasedAssocRejectAttr(
89                             assocRejectData.oceRssiBasedAssocRejectData.deltaRssi,
90                             assocRejectData.oceRssiBasedAssocRejectData.retryDelayS);
91         } else {
92             this.oceRssiBasedAssocRejectInfo = null;
93         }
94     }
95 
96     @Override
toString()97     public String toString() {
98         StringBuffer sb = new StringBuffer();
99         sb.append(" ssid: ").append(ssid);
100         sb.append(" bssid: ").append(bssid);
101         sb.append(" statusCode: ").append(statusCode);
102         sb.append(" timedOut: ").append(timedOut);
103         sb.append(" oceRssiBasedAssocRejectInfo: ").append(oceRssiBasedAssocRejectInfo);
104         sb.append(" mboAssocDisallowedInfo: ").append(mboAssocDisallowedInfo);
105 
106         return sb.toString();
107     }
108 }
109