1 /* 2 * Copyright (C) 2019 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 19 import android.annotation.NonNull; 20 import android.hardware.wifi.supplicant.V1_4.ISupplicantStaIfaceCallback.AssociationRejectionData; 21 import android.net.wifi.WifiManager; 22 23 import com.android.server.wifi.hotspot2.WnmData; 24 import com.android.server.wifi.util.NativeUtil; 25 26 import java.util.ArrayList; 27 28 abstract class SupplicantStaIfaceCallbackV1_4Impl extends 29 android.hardware.wifi.supplicant.V1_4.ISupplicantStaIfaceCallback.Stub { 30 private static final String TAG = SupplicantStaIfaceCallbackV1_4Impl.class.getSimpleName(); 31 private final SupplicantStaIfaceHal mStaIfaceHal; 32 private final String mIfaceName; 33 private final WifiMonitor mWifiMonitor; 34 private final Object mLock; 35 private final SupplicantStaIfaceHal.SupplicantStaIfaceHalCallbackV1_3 mCallbackV13; 36 private final SupplicantStaIfaceHal.SupplicantStaIfaceHalCallback mCallbackV10; 37 SupplicantStaIfaceCallbackV1_4Impl(@onNull SupplicantStaIfaceHal staIfaceHal, @NonNull String ifaceName, @NonNull Object lock, @NonNull WifiMonitor wifiMonitor)38 SupplicantStaIfaceCallbackV1_4Impl(@NonNull SupplicantStaIfaceHal staIfaceHal, 39 @NonNull String ifaceName, @NonNull Object lock, 40 @NonNull WifiMonitor wifiMonitor) { 41 mStaIfaceHal = staIfaceHal; 42 mIfaceName = ifaceName; 43 mLock = lock; 44 mWifiMonitor = wifiMonitor; 45 // Create an older callback for function delegation, 46 // and it would cascadingly create older one. 47 mCallbackV13 = mStaIfaceHal.new SupplicantStaIfaceHalCallbackV1_3(mIfaceName); 48 mCallbackV10 = mStaIfaceHal.new SupplicantStaIfaceHalCallback(mIfaceName); 49 } 50 51 @Override onNetworkAdded(int id)52 public void onNetworkAdded(int id) { 53 mCallbackV13.onNetworkAdded(id); 54 } 55 56 @Override onNetworkRemoved(int id)57 public void onNetworkRemoved(int id) { 58 mCallbackV13.onNetworkRemoved(id); 59 } 60 61 @Override onStateChanged(int newState, byte[ ] bssid, int id, ArrayList<Byte> ssid)62 public void onStateChanged(int newState, byte[/* 6 */] bssid, int id, 63 ArrayList<Byte> ssid) { 64 mCallbackV13.onStateChanged(newState, bssid, id, ssid); 65 } 66 67 @Override onAnqpQueryDone_1_4(byte[ ] bssid, AnqpData data, Hs20AnqpData hs20Data)68 public void onAnqpQueryDone_1_4(byte[/* 6 */] bssid, 69 AnqpData data, 70 Hs20AnqpData hs20Data) { 71 synchronized (mLock) { 72 mStaIfaceHal.logCallback("onAnqpQueryDone_1_4"); 73 mCallbackV10.onAnqpQueryDone(bssid, data.V1_0 /* v1.0 elemnt */, hs20Data, 74 data /* v1.4 element */); 75 } 76 } 77 78 @Override onAnqpQueryDone(byte[ ] bssid, android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback.AnqpData data, Hs20AnqpData hs20Data)79 public void onAnqpQueryDone(byte[/* 6 */] bssid, 80 android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback.AnqpData data, 81 Hs20AnqpData hs20Data) { 82 mCallbackV13.onAnqpQueryDone(bssid, data, hs20Data); 83 } 84 85 @Override onHs20IconQueryDone(byte[ ] bssid, String fileName, ArrayList<Byte> data)86 public void onHs20IconQueryDone(byte[/* 6 */] bssid, String fileName, 87 ArrayList<Byte> data) { 88 mCallbackV13.onHs20IconQueryDone(bssid, fileName, data); 89 } 90 91 @Override onHs20SubscriptionRemediation(byte[ ] bssid, byte osuMethod, String url)92 public void onHs20SubscriptionRemediation(byte[/* 6 */] bssid, 93 byte osuMethod, String url) { 94 mCallbackV13.onHs20SubscriptionRemediation(bssid, osuMethod, url); 95 } 96 97 @Override onHs20DeauthImminentNotice(byte[ ] bssid, int reasonCode, int reAuthDelayInSec, String url)98 public void onHs20DeauthImminentNotice(byte[/* 6 */] bssid, int reasonCode, 99 int reAuthDelayInSec, String url) { 100 mCallbackV13.onHs20DeauthImminentNotice(bssid, reasonCode, reAuthDelayInSec, url); 101 } 102 103 @Override onDisconnected(byte[ ] bssid, boolean locallyGenerated, int reasonCode)104 public void onDisconnected(byte[/* 6 */] bssid, boolean locallyGenerated, 105 int reasonCode) { 106 mCallbackV13.onDisconnected(bssid, locallyGenerated, reasonCode); 107 } 108 109 @Override onAssociationRejected_1_4(AssociationRejectionData assocRejectData)110 public void onAssociationRejected_1_4(AssociationRejectionData assocRejectData) { 111 synchronized (mLock) { 112 mStaIfaceHal.logCallback("onAssociationRejected_1_4"); 113 mCallbackV10.onAssociationRejected(assocRejectData); 114 } 115 } 116 117 @Override onAssociationRejected(byte[ ] bssid, int statusCode, boolean timedOut)118 public void onAssociationRejected(byte[/* 6 */] bssid, int statusCode, 119 boolean timedOut) { 120 mCallbackV13.onAssociationRejected(bssid, statusCode, timedOut); 121 } 122 123 @Override onAuthenticationTimeout(byte[ ] bssid)124 public void onAuthenticationTimeout(byte[/* 6 */] bssid) { 125 mCallbackV13.onAuthenticationTimeout(bssid); 126 } 127 128 @Override onBssidChanged(byte reason, byte[ ] bssid)129 public void onBssidChanged(byte reason, byte[/* 6 */] bssid) { 130 mCallbackV13.onBssidChanged(reason, bssid); 131 } 132 133 @Override onEapFailure()134 public void onEapFailure() { 135 mCallbackV13.onEapFailure(); 136 } 137 138 @Override onEapFailure_1_1(int code)139 public void onEapFailure_1_1(int code) { 140 mCallbackV13.onEapFailure_1_1(code); 141 } 142 143 @Override onEapFailure_1_3(int code)144 public void onEapFailure_1_3(int code) { 145 mWifiMonitor.broadcastAuthenticationFailureEvent( 146 mIfaceName, WifiManager.ERROR_AUTH_FAILURE_EAP_FAILURE, code); 147 } 148 149 @Override onWpsEventSuccess()150 public void onWpsEventSuccess() { 151 mCallbackV13.onWpsEventSuccess(); 152 } 153 154 @Override onWpsEventFail(byte[ ] bssid, short configError, short errorInd)155 public void onWpsEventFail(byte[/* 6 */] bssid, short configError, short errorInd) { 156 mCallbackV13.onWpsEventFail(bssid, configError, errorInd); 157 } 158 159 @Override onWpsEventPbcOverlap()160 public void onWpsEventPbcOverlap() { 161 mCallbackV13.onWpsEventPbcOverlap(); 162 } 163 164 @Override onExtRadioWorkStart(int id)165 public void onExtRadioWorkStart(int id) { 166 mCallbackV13.onExtRadioWorkStart(id); 167 } 168 169 @Override onExtRadioWorkTimeout(int id)170 public void onExtRadioWorkTimeout(int id) { 171 mCallbackV13.onExtRadioWorkTimeout(id); 172 } 173 174 @Override onDppSuccessConfigReceived(ArrayList<Byte> ssid, String password, byte[] psk, int securityAkm)175 public void onDppSuccessConfigReceived(ArrayList<Byte> ssid, String password, 176 byte[] psk, int securityAkm) { 177 mCallbackV13.onDppSuccessConfigReceived( 178 ssid, password, psk, securityAkm); 179 } 180 181 @Override onDppSuccessConfigSent()182 public void onDppSuccessConfigSent() { 183 mCallbackV13.onDppSuccessConfigSent(); 184 } 185 186 @Override onDppProgress(int code)187 public void onDppProgress(int code) { 188 mCallbackV13.onDppProgress(code); 189 } 190 191 @Override onDppFailure(int code)192 public void onDppFailure(int code) { 193 mCallbackV13.onDppFailure(code); 194 } 195 196 @Override onPmkCacheAdded(long expirationTimeInSec, ArrayList<Byte> serializedEntry)197 public void onPmkCacheAdded(long expirationTimeInSec, ArrayList<Byte> serializedEntry) { 198 mCallbackV13.onPmkCacheAdded(expirationTimeInSec, serializedEntry); 199 } 200 201 @Override onDppProgress_1_3(int code)202 public void onDppProgress_1_3(int code) { 203 mCallbackV13.onDppProgress_1_3(code); 204 } 205 206 @Override onDppFailure_1_3(int code, String ssid, String channelList, ArrayList<Short> bandList)207 public void onDppFailure_1_3(int code, String ssid, String channelList, 208 ArrayList<Short> bandList) { 209 mCallbackV13.onDppFailure_1_3(code, ssid, channelList, bandList); 210 } 211 212 @Override onDppSuccess(int code)213 public void onDppSuccess(int code) { 214 mCallbackV13.onDppSuccess(code); 215 } 216 217 @Override onBssTmHandlingDone(BssTmData tmData)218 public void onBssTmHandlingDone(BssTmData tmData) { 219 mCallbackV13.onBssTmHandlingDone(tmData); 220 } 221 222 @Override onStateChanged_1_3(int newState, byte[ ] bssid, int id, ArrayList<Byte> ssid, boolean filsHlpSent)223 public void onStateChanged_1_3(int newState, byte[/* 6 */] bssid, int id, 224 ArrayList<Byte> ssid, boolean filsHlpSent) { 225 mCallbackV13.onStateChanged_1_3(newState, bssid, id, ssid, filsHlpSent); 226 } 227 228 @Override onHs20TermsAndConditionsAcceptanceRequestedNotification(byte[ ] bssid, String url)229 public void onHs20TermsAndConditionsAcceptanceRequestedNotification(byte[/* 6 */] bssid, 230 String url) { 231 synchronized (mLock) { 232 mStaIfaceHal.logCallback("onHs20TermsAndConditionsAcceptanceRequestedNotification"); 233 mWifiMonitor.broadcastWnmEvent(mIfaceName, 234 WnmData.createTermsAndConditionsAccetanceRequiredEvent( 235 NativeUtil.macAddressToLong(bssid), url)); 236 } 237 } 238 239 @Override onNetworkNotFound(ArrayList<Byte> ssid)240 public void onNetworkNotFound(ArrayList<Byte> ssid) { 241 mStaIfaceHal.logCallback("onNetworkNotFoundNotification"); 242 mWifiMonitor.broadcastNetworkNotFoundEvent(mIfaceName, NativeUtil.encodeSsid(ssid)); 243 } 244 } 245