SupplicantStaNetworkHal.java revision d95fa596d07855b70ff18a50a48e773155a919f5
1/*
2 * Copyright (C) 2017 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 */
16package com.android.server.wifi;
17
18import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork;
19import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetworkCallback;
20import android.hardware.wifi.supplicant.V1_0.SupplicantStatus;
21import android.hardware.wifi.supplicant.V1_0.SupplicantStatusCode;
22import android.net.wifi.WifiConfiguration;
23import android.net.wifi.WifiEnterpriseConfig;
24import android.os.HandlerThread;
25import android.os.RemoteException;
26import android.text.TextUtils;
27import android.util.Log;
28import android.util.MutableBoolean;
29
30import com.android.internal.annotations.VisibleForTesting;
31import com.android.internal.util.ArrayUtils;
32import com.android.server.wifi.util.NativeUtil;
33
34import java.util.ArrayList;
35import java.util.BitSet;
36import java.util.HashMap;
37import java.util.Map;
38import java.util.regex.Matcher;
39import java.util.regex.Pattern;
40
41/**
42 * Wrapper class for ISupplicantStaNetwork HAL calls. Gets and sets supplicant sta network variables
43 * and interacts with networks.
44 * Public fields should be treated as invalid until their 'get' method is called, which will set the
45 * value if it returns true
46 */
47public class SupplicantStaNetworkHal {
48    private static final String TAG = "SupplicantStaNetworkHal";
49    private static final boolean DBG = false;
50    @VisibleForTesting
51    public static final String ID_STRING_KEY_FQDN = "fqdn";
52    @VisibleForTesting
53    public static final String ID_STRING_KEY_CREATOR_UID = "creatorUid";
54    @VisibleForTesting
55    public static final String ID_STRING_KEY_CONFIG_KEY = "configKey";
56
57    /**
58     * Regex pattern for extracting the GSM sim authentication response params from a string.
59     * Matches a strings like the following: "[:kc:<kc_value>:sres:<sres_value>]";
60     */
61    private static final Pattern GSM_AUTH_RESPONSE_PARAMS_PATTERN =
62            Pattern.compile(":kc:([0-9a-f]+):sres:([0-9a-f]+)");
63    /**
64     * Regex pattern for extracting the UMTS sim authentication response params from a string.
65     * Matches a strings like the following: ":ik:<ik_value>:ck:<ck_value>:res:<res_value>";
66     */
67    private static final Pattern UMTS_AUTH_RESPONSE_PARAMS_PATTERN =
68            Pattern.compile(":ik:([0-9a-f]+):ck:([0-9a-f]+):res:([0-9a-f]+)");
69    /**
70     * Regex pattern for extracting the UMTS sim auts response params from a string.
71     * Matches a strings like the following: ":<auts_value>";
72     */
73    private static final Pattern UMTS_AUTS_RESPONSE_PARAMS_PATTERN = Pattern.compile("([0-9a-f]+)");
74
75    private final Object mLock = new Object();
76    private ISupplicantStaNetwork mISupplicantStaNetwork = null;
77    private final HandlerThread mHandlerThread;
78    private int mNetworkId;
79    private String mIfaceName;
80    private ArrayList<Byte> mSsid;
81    private byte[/* 6 */] mBssid;
82    private boolean mScanSsid;
83    private int mKeyMgmtMask;
84    private int mProtoMask;
85    private int mAuthAlgMask;
86    private int mGroupCipherMask;
87    private int mPairwiseCipherMask;
88    private String mPskPassphrase;
89    private ArrayList<Byte> mWepKey;
90    private int mWepTxKeyIdx;
91    private boolean mRequirePmf;
92    private String mIdStr;
93    private int mEapMethod;
94    private int mEapPhase2Method;
95    private ArrayList<Byte> mEapIdentity;
96    private ArrayList<Byte> mEapAnonymousIdentity;
97    private ArrayList<Byte> mEapPassword;
98    private String mEapCACert;
99    private String mEapCAPath;
100    private String mEapClientCert;
101    private String mEapPrivateKey;
102    private String mEapSubjectMatch;
103    private String mEapAltSubjectMatch;
104    private boolean mEapEngine;
105    private String mEapEngineID;
106    private String mEapDomainSuffixMatch;
107
108    SupplicantStaNetworkHal(ISupplicantStaNetwork iSupplicantStaNetwork,
109                            HandlerThread handlerThread) {
110        mISupplicantStaNetwork = iSupplicantStaNetwork;
111        mHandlerThread = handlerThread;
112    }
113
114    /**
115     * Read network variables from wpa_supplicant into the provided WifiConfiguration object.
116     *
117     * @param config        WifiConfiguration object to be populated.
118     * @param networkExtras Map of network extras parsed from wpa_supplicant.
119     * @return true if succeeds, false otherwise.
120     */
121    public boolean loadWifiConfiguration(WifiConfiguration config,
122                                         Map<String, String> networkExtras) {
123        if (config == null) return false;
124        /** SSID */
125        config.SSID = null;
126        if (getSsid() && !ArrayUtils.isEmpty(mSsid)) {
127            config.SSID = NativeUtil.encodeSsid(mSsid);
128        } else {
129            Log.e(TAG, "failed to read ssid");
130            return false;
131        }
132        /** BSSID */
133        config.getNetworkSelectionStatus().setNetworkSelectionBSSID(null);
134        if (getBssid() && !ArrayUtils.isEmpty(mBssid)) {
135            config.getNetworkSelectionStatus().setNetworkSelectionBSSID(
136                    NativeUtil.macAddressFromByteArray(mBssid));
137        }
138        /** Scan SSID (Is Hidden Network?) */
139        config.hiddenSSID = false;
140        if (getScanSsid()) {
141            config.hiddenSSID = mScanSsid;
142        }
143        /** Require PMF*/
144        config.requirePMF = false;
145        if (getRequirePmf()) {
146            config.requirePMF = mRequirePmf;
147        }
148        /** WEP keys **/
149        config.wepTxKeyIndex = -1;
150        if (getWepTxKeyIdx()) {
151            config.wepTxKeyIndex = mWepTxKeyIdx;
152        }
153        for (int i = 0; i < 4; i++) {
154            config.wepKeys[i] = null;
155            if (getWepKey(i) && !ArrayUtils.isEmpty(mWepKey)) {
156                config.wepKeys[i] = NativeUtil.stringFromByteArrayList(mWepKey);
157            }
158        }
159        /** PSK pass phrase */
160        config.preSharedKey = null;
161        if (getPskPassphrase() && !TextUtils.isEmpty(mPskPassphrase)) {
162            config.preSharedKey = mPskPassphrase;
163        }
164        /** allowedKeyManagement */
165        if (getKeyMgmt()) {
166            config.allowedKeyManagement =
167                    supplicantToWifiConfigurationKeyMgmtMask(mKeyMgmtMask);
168        }
169        /** allowedProtocols */
170        if (getProto()) {
171            config.allowedProtocols =
172                    supplicantToWifiConfigurationProtoMask(mProtoMask);
173        }
174        /** allowedAuthAlgorithms */
175        if (getAuthAlg()) {
176            config.allowedAuthAlgorithms =
177                    supplicantToWifiConfigurationAuthAlgMask(mAuthAlgMask);
178        }
179        /** allowedGroupCiphers */
180        if (getGroupCipher()) {
181            config.allowedGroupCiphers =
182                    supplicantToWifiConfigurationGroupCipherMask(mGroupCipherMask);
183        }
184        /** allowedPairwiseCiphers */
185        if (getPairwiseCipher()) {
186            config.allowedPairwiseCiphers =
187                    supplicantToWifiConfigurationPairwiseCipherMask(mPairwiseCipherMask);
188        }
189        /** metadata: idstr */
190        if (getIdStr() && !TextUtils.isEmpty(mIdStr)) {
191            Map<String, String> metadata = WifiNative.parseNetworkExtra(mIdStr);
192            networkExtras.putAll(metadata);
193        } else {
194            Log.e(TAG, "getIdStr failed");
195            return false;
196        }
197        return loadWifiEnterpriseConfig(config.SSID, config.enterpriseConfig);
198    }
199
200    /**
201     * Save an entire WifiConfiguration to wpa_supplicant via HIDL.
202     *
203     * @param config WifiConfiguration object to be saved.
204     * @return true if succeeds, false otherwise.
205     */
206    public boolean saveWifiConfiguration(WifiConfiguration config) {
207        if (config == null) return false;
208        /** SSID */
209        if (config.SSID != null) {
210            if (!setSsid(NativeUtil.decodeSsid(config.SSID))) {
211                Log.e(TAG, "failed to set SSID: " + config.SSID);
212                return false;
213            }
214        }
215        /** BSSID */
216        String bssidStr = config.getNetworkSelectionStatus().getNetworkSelectionBSSID();
217        if (bssidStr != null) {
218            byte[] bssid = NativeUtil.macAddressToByteArray(bssidStr);
219            if (!setBssid(bssid)) {
220                Log.e(TAG, "failed to set BSSID: " + bssidStr);
221                return false;
222            }
223        }
224        /** Pre Shared Key */
225        if (config.preSharedKey != null && !setPskPassphrase(config.preSharedKey)) {
226            Log.e(TAG, "failed to set psk");
227            return false;
228        }
229        /** Wep Keys */
230        boolean hasSetKey = false;
231        if (config.wepKeys != null) {
232            for (int i = 0; i < config.wepKeys.length; i++) {
233                // Prevent client screw-up by passing in a WifiConfiguration we gave it
234                // by preventing "*" as a key.
235                if (config.wepKeys[i] != null && !config.wepKeys[i].equals("*")) {
236                    if (!setWepKey(i, NativeUtil.stringToByteArrayList(config.wepKeys[i]))) {
237                        Log.e(TAG, "failed to set wep_key " + i);
238                        return false;
239                    }
240                    hasSetKey = true;
241                }
242            }
243        }
244        /** Wep Tx Key Idx */
245        if (hasSetKey) {
246            if (!setWepTxKeyIdx(config.wepTxKeyIndex)) {
247                Log.e(TAG, "failed to set wep_tx_keyidx: " + config.wepTxKeyIndex);
248                return false;
249            }
250        }
251        /** HiddenSSID */
252        if (!setScanSsid(config.hiddenSSID)) {
253            Log.e(TAG, config.SSID + ": failed to set hiddenSSID: " + config.hiddenSSID);
254            return false;
255        }
256        /** RequirePMF */
257        if (!setRequirePmf(config.requirePMF)) {
258            Log.e(TAG, config.SSID + ": failed to set requirePMF: " + config.requirePMF);
259            return false;
260        }
261        /** Key Management Scheme */
262        if (config.allowedKeyManagement.cardinality() != 0
263                && !setKeyMgmt(wifiConfigurationToSupplicantKeyMgmtMask(
264                config.allowedKeyManagement))) {
265            Log.e(TAG, "failed to set Key Management");
266            return false;
267        }
268        /** Security Protocol */
269        if (config.allowedProtocols.cardinality() != 0
270                && !setProto(wifiConfigurationToSupplicantProtoMask(config.allowedProtocols))) {
271            Log.e(TAG, "failed to set Security Protocol");
272            return false;
273        }
274        /** Auth Algorithm */
275        if (config.allowedAuthAlgorithms.cardinality() != 0
276                && !setAuthAlg(wifiConfigurationToSupplicantAuthAlgMask(
277                config.allowedAuthAlgorithms))) {
278            Log.e(TAG, "failed to set AuthAlgorithm");
279            return false;
280        }
281        /** Group Cipher */
282        if (config.allowedGroupCiphers.cardinality() != 0
283                && !setGroupCipher(wifiConfigurationToSupplicantGroupCipherMask(
284                config.allowedGroupCiphers))) {
285            Log.e(TAG, "failed to set Group Cipher");
286            return false;
287        }
288        /** Pairwise Cipher*/
289        if (config.allowedPairwiseCiphers.cardinality() != 0
290                && !setPairwiseCipher(wifiConfigurationToSupplicantPairwiseCipherMask(
291                        config.allowedPairwiseCiphers))) {
292            Log.e(TAG, "failed to set PairwiseCipher");
293            return false;
294        }
295        /** metadata: FQDN + ConfigKey + CreatorUid */
296        final Map<String, String> metadata = new HashMap<String, String>();
297        if (config.isPasspoint()) {
298            metadata.put(ID_STRING_KEY_FQDN, config.FQDN);
299        }
300        metadata.put(ID_STRING_KEY_CONFIG_KEY, config.configKey());
301        metadata.put(ID_STRING_KEY_CREATOR_UID, Integer.toString(config.creatorUid));
302        if (!setIdStr(WifiNative.createNetworkExtra(metadata))) {
303            Log.e(TAG, "failed to set id string");
304            return false;
305        }
306        /** UpdateIdentifier */
307        if (config.updateIdentifier != null
308                && !setUpdateIdentifier(Integer.parseInt(config.updateIdentifier))) {
309            Log.e(TAG, "failed to set update identifier");
310            return false;
311        }
312        // Finish here if no EAP config to set
313        if (config.enterpriseConfig == null
314                || config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.NONE) {
315            return true;
316        } else {
317            return saveWifiEnterpriseConfig(config.SSID, config.enterpriseConfig);
318        }
319    }
320
321    /**
322     * Read network variables from wpa_supplicant into the provided WifiEnterpriseConfig object.
323     *
324     * @param ssid SSID of the network. (Used for logging purposes only)
325     * @param eapConfig WifiEnterpriseConfig object to be populated.
326     * @return true if succeeds, false otherwise.
327     */
328    private boolean loadWifiEnterpriseConfig(String ssid, WifiEnterpriseConfig eapConfig) {
329        if (eapConfig == null) return false;
330        /** EAP method */
331        if (getEapMethod()) {
332            eapConfig.setEapMethod(supplicantToWifiConfigurationEapMethod(mEapMethod));
333        } else {
334            // Invalid eap method could be because it's not an enterprise config.
335            Log.e(TAG, "failed to get eap method. Assumimg not an enterprise network");
336            return true;
337        }
338        /** EAP Phase 2 method */
339        if (getEapPhase2Method()) {
340            eapConfig.setPhase2Method(
341                    supplicantToWifiConfigurationEapPhase2Method(mEapPhase2Method));
342        } else {
343            // We cannot have an invalid eap phase 2 method. Return failure.
344            Log.e(TAG, "failed to get eap phase2 method");
345            return false;
346        }
347        /** EAP Identity */
348        if (getEapIdentity() && !ArrayUtils.isEmpty(mEapIdentity)) {
349            eapConfig.setFieldValue(
350                    WifiEnterpriseConfig.IDENTITY_KEY,
351                    NativeUtil.stringFromByteArrayList(mEapIdentity));
352        }
353        /** EAP Anonymous Identity */
354        if (getEapAnonymousIdentity() && !ArrayUtils.isEmpty(mEapAnonymousIdentity)) {
355            eapConfig.setFieldValue(
356                    WifiEnterpriseConfig.ANON_IDENTITY_KEY,
357                    NativeUtil.stringFromByteArrayList(mEapAnonymousIdentity));
358        }
359        /** EAP Password */
360        if (getEapPassword() && !ArrayUtils.isEmpty(mEapPassword)) {
361            eapConfig.setFieldValue(
362                    WifiEnterpriseConfig.PASSWORD_KEY,
363                    NativeUtil.stringFromByteArrayList(mEapPassword));
364        }
365        /** EAP Client Cert */
366        if (getEapClientCert() && !TextUtils.isEmpty(mEapClientCert)) {
367            eapConfig.setFieldValue(WifiEnterpriseConfig.CLIENT_CERT_KEY, mEapClientCert);
368        }
369        /** EAP CA Cert */
370        if (getEapCACert() && !TextUtils.isEmpty(mEapCACert)) {
371            eapConfig.setFieldValue(WifiEnterpriseConfig.CA_CERT_KEY, mEapCACert);
372        }
373        /** EAP Subject Match */
374        if (getEapSubjectMatch() && !TextUtils.isEmpty(mEapSubjectMatch)) {
375            eapConfig.setFieldValue(WifiEnterpriseConfig.SUBJECT_MATCH_KEY, mEapSubjectMatch);
376        }
377        /** EAP Engine ID */
378        if (getEapEngineID() && !TextUtils.isEmpty(mEapEngineID)) {
379            eapConfig.setFieldValue(WifiEnterpriseConfig.ENGINE_ID_KEY, mEapEngineID);
380        }
381        /** EAP Engine. Set this only if the engine id is non null. */
382        if (getEapEngine() && !TextUtils.isEmpty(mEapEngineID)) {
383            eapConfig.setFieldValue(
384                    WifiEnterpriseConfig.ENGINE_KEY,
385                    mEapEngine
386                            ? WifiEnterpriseConfig.ENGINE_ENABLE
387                            : WifiEnterpriseConfig.ENGINE_DISABLE);
388        }
389        /** EAP Private Key */
390        if (getEapPrivateKey() && !TextUtils.isEmpty(mEapPrivateKey)) {
391            eapConfig.setFieldValue(WifiEnterpriseConfig.PRIVATE_KEY_ID_KEY, mEapPrivateKey);
392        }
393        /** EAP Alt Subject Match */
394        if (getEapAltSubjectMatch() && !TextUtils.isEmpty(mEapAltSubjectMatch)) {
395            eapConfig.setFieldValue(WifiEnterpriseConfig.ALTSUBJECT_MATCH_KEY, mEapAltSubjectMatch);
396        }
397        /** EAP Domain Suffix Match */
398        if (getEapDomainSuffixMatch() && !TextUtils.isEmpty(mEapDomainSuffixMatch)) {
399            eapConfig.setFieldValue(
400                    WifiEnterpriseConfig.DOM_SUFFIX_MATCH_KEY, mEapDomainSuffixMatch);
401        }
402        /** EAP CA Path*/
403        if (getEapCAPath() && !TextUtils.isEmpty(mEapCAPath)) {
404            eapConfig.setFieldValue(WifiEnterpriseConfig.CA_PATH_KEY, mEapCAPath);
405        }
406        return true;
407    }
408
409    /**
410     * Save network variables from the provided WifiEnterpriseConfig object to wpa_supplicant.
411     *
412     * @param ssid SSID of the network. (Used for logging purposes only)
413     * @param eapConfig WifiEnterpriseConfig object to be saved.
414     * @return true if succeeds, false otherwise.
415     */
416    private boolean saveWifiEnterpriseConfig(String ssid, WifiEnterpriseConfig eapConfig) {
417        if (eapConfig == null) return false;
418        /** EAP method */
419        if (!setEapMethod(wifiConfigurationToSupplicantEapMethod(eapConfig.getEapMethod()))) {
420            Log.e(TAG, ssid + ": failed to set eap method: " + eapConfig.getEapMethod());
421            return false;
422        }
423        /** EAP Phase 2 method */
424        if (!setEapPhase2Method(wifiConfigurationToSupplicantEapPhase2Method(
425                eapConfig.getPhase2Method()))) {
426            Log.e(TAG, ssid + ": failed to set eap phase 2 method: " + eapConfig.getPhase2Method());
427            return false;
428        }
429        String eapParam = null;
430        /** EAP Identity */
431        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.IDENTITY_KEY);
432        if (!TextUtils.isEmpty(eapParam)
433                && !setEapIdentity(NativeUtil.stringToByteArrayList(eapParam))) {
434            Log.e(TAG, ssid + ": failed to set eap identity: " + eapParam);
435            return false;
436        }
437        /** EAP Anonymous Identity */
438        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.ANON_IDENTITY_KEY);
439        if (!TextUtils.isEmpty(eapParam)
440                && !setEapAnonymousIdentity(NativeUtil.stringToByteArrayList(eapParam))) {
441            Log.e(TAG, ssid + ": failed to set eap anonymous identity: " + eapParam);
442            return false;
443        }
444        /** EAP Password */
445        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.PASSWORD_KEY);
446        if (!TextUtils.isEmpty(eapParam)
447                && !setEapPassword(NativeUtil.stringToByteArrayList(eapParam))) {
448            Log.e(TAG, ssid + ": failed to set eap password");
449            return false;
450        }
451        /** EAP Client Cert */
452        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.CLIENT_CERT_KEY);
453        if (!TextUtils.isEmpty(eapParam) && !setEapClientCert(eapParam)) {
454            Log.e(TAG, ssid + ": failed to set eap client cert: " + eapParam);
455            return false;
456        }
457        /** EAP CA Cert */
458        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.CA_CERT_KEY);
459        if (!TextUtils.isEmpty(eapParam) && !setEapCACert(eapParam)) {
460            Log.e(TAG, ssid + ": failed to set eap ca cert: " + eapParam);
461            return false;
462        }
463        /** EAP Subject Match */
464        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.SUBJECT_MATCH_KEY);
465        if (!TextUtils.isEmpty(eapParam) && !setEapSubjectMatch(eapParam)) {
466            Log.e(TAG, ssid + ": failed to set eap subject match: " + eapParam);
467            return false;
468        }
469        /** EAP Engine ID */
470        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.ENGINE_ID_KEY);
471        if (!TextUtils.isEmpty(eapParam) && !setEapEngineID(eapParam)) {
472            Log.e(TAG, ssid + ": failed to set eap engine id: " + eapParam);
473            return false;
474        }
475        /** EAP Engine */
476        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.ENGINE_KEY);
477        if (!TextUtils.isEmpty(eapParam) && !setEapEngine(
478                eapParam.equals(WifiEnterpriseConfig.ENGINE_ENABLE) ? true : false)) {
479            Log.e(TAG, ssid + ": failed to set eap engine: " + eapParam);
480            return false;
481        }
482        /** EAP Private Key */
483        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.PRIVATE_KEY_ID_KEY);
484        if (!TextUtils.isEmpty(eapParam) && !setEapPrivateKey(eapParam)) {
485            Log.e(TAG, ssid + ": failed to set eap private key: " + eapParam);
486            return false;
487        }
488        /** EAP Alt Subject Match */
489        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.ALTSUBJECT_MATCH_KEY);
490        if (!TextUtils.isEmpty(eapParam) && !setEapAltSubjectMatch(eapParam)) {
491            Log.e(TAG, ssid + ": failed to set eap alt subject match: " + eapParam);
492            return false;
493        }
494        /** EAP Domain Suffix Match */
495        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.DOM_SUFFIX_MATCH_KEY);
496        if (!TextUtils.isEmpty(eapParam) && !setEapDomainSuffixMatch(eapParam)) {
497            Log.e(TAG, ssid + ": failed to set eap domain suffix match: " + eapParam);
498            return false;
499        }
500        /** EAP CA Path*/
501        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.CA_PATH_KEY);
502        if (!TextUtils.isEmpty(eapParam) && !setEapCAPath(eapParam)) {
503            Log.e(TAG, ssid + ": failed to set eap ca path: " + eapParam);
504            return false;
505        }
506
507        /** EAP Proactive Key Caching */
508        eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.OPP_KEY_CACHING);
509        if (!TextUtils.isEmpty(eapParam)
510                && !setEapProactiveKeyCaching(eapParam.equals("1") ? true : false)) {
511            Log.e(TAG, ssid + ": failed to set proactive key caching: " + eapParam);
512            return false;
513        }
514        return true;
515    }
516
517    /**
518     * Maps WifiConfiguration Key Management BitSet to Supplicant HIDL bitmask int
519     * TODO(b/32571829): Update mapping when fast transition keys are added
520     * @return bitmask int describing the allowed Key Management schemes, readable by the Supplicant
521     *         HIDL hal
522     */
523    private static int wifiConfigurationToSupplicantKeyMgmtMask(BitSet keyMgmt) {
524        int mask = 0;
525        for (int bit = keyMgmt.nextSetBit(0); bit != -1; bit = keyMgmt.nextSetBit(bit + 1)) {
526            switch (bit) {
527                case WifiConfiguration.KeyMgmt.NONE:
528                    mask |= ISupplicantStaNetwork.KeyMgmtMask.NONE;
529                    break;
530                case WifiConfiguration.KeyMgmt.WPA_PSK:
531                    mask |= ISupplicantStaNetwork.KeyMgmtMask.WPA_PSK;
532                    break;
533                case WifiConfiguration.KeyMgmt.WPA_EAP:
534                    mask |= ISupplicantStaNetwork.KeyMgmtMask.WPA_EAP;
535                    break;
536                case WifiConfiguration.KeyMgmt.IEEE8021X:
537                    mask |= ISupplicantStaNetwork.KeyMgmtMask.IEEE8021X;
538                    break;
539                case WifiConfiguration.KeyMgmt.OSEN:
540                    mask |= ISupplicantStaNetwork.KeyMgmtMask.OSEN;
541                    break;
542                case WifiConfiguration.KeyMgmt.FT_PSK:
543                    mask |= ISupplicantStaNetwork.KeyMgmtMask.FT_PSK;
544                    break;
545                case WifiConfiguration.KeyMgmt.FT_EAP:
546                    mask |= ISupplicantStaNetwork.KeyMgmtMask.FT_EAP;
547                    break;
548                case WifiConfiguration.KeyMgmt.WPA2_PSK: // This should never happen
549                default:
550                    throw new IllegalArgumentException(
551                            "Invalid protoMask bit in keyMgmt: " + bit);
552            }
553        }
554        return mask;
555    }
556
557    private static int wifiConfigurationToSupplicantProtoMask(BitSet protoMask) {
558        int mask = 0;
559        for (int bit = protoMask.nextSetBit(0); bit != -1; bit = protoMask.nextSetBit(bit + 1)) {
560            switch (bit) {
561                case WifiConfiguration.Protocol.WPA:
562                    mask |= ISupplicantStaNetwork.ProtoMask.WPA;
563                    break;
564                case WifiConfiguration.Protocol.RSN:
565                    mask |= ISupplicantStaNetwork.ProtoMask.RSN;
566                    break;
567                case WifiConfiguration.Protocol.OSEN:
568                    mask |= ISupplicantStaNetwork.ProtoMask.OSEN;
569                    break;
570                default:
571                    throw new IllegalArgumentException(
572                            "Invalid protoMask bit in wificonfig: " + bit);
573            }
574        }
575        return mask;
576    };
577
578    private static int wifiConfigurationToSupplicantAuthAlgMask(BitSet authAlgMask) {
579        int mask = 0;
580        for (int bit = authAlgMask.nextSetBit(0); bit != -1;
581                bit = authAlgMask.nextSetBit(bit + 1)) {
582            switch (bit) {
583                case WifiConfiguration.AuthAlgorithm.OPEN:
584                    mask |= ISupplicantStaNetwork.AuthAlgMask.OPEN;
585                    break;
586                case WifiConfiguration.AuthAlgorithm.SHARED:
587                    mask |= ISupplicantStaNetwork.AuthAlgMask.SHARED;
588                    break;
589                case WifiConfiguration.AuthAlgorithm.LEAP:
590                    mask |= ISupplicantStaNetwork.AuthAlgMask.LEAP;
591                    break;
592                default:
593                    throw new IllegalArgumentException(
594                            "Invalid authAlgMask bit in wificonfig: " + bit);
595            }
596        }
597        return mask;
598    };
599
600    private static int wifiConfigurationToSupplicantGroupCipherMask(BitSet groupCipherMask) {
601        int mask = 0;
602        for (int bit = groupCipherMask.nextSetBit(0); bit != -1; bit =
603                groupCipherMask.nextSetBit(bit + 1)) {
604            switch (bit) {
605                case WifiConfiguration.GroupCipher.WEP40:
606                    mask |= ISupplicantStaNetwork.GroupCipherMask.WEP40;
607                    break;
608                case WifiConfiguration.GroupCipher.WEP104:
609                    mask |= ISupplicantStaNetwork.GroupCipherMask.WEP104;
610                    break;
611                case WifiConfiguration.GroupCipher.TKIP:
612                    mask |= ISupplicantStaNetwork.GroupCipherMask.TKIP;
613                    break;
614                case WifiConfiguration.GroupCipher.CCMP:
615                    mask |= ISupplicantStaNetwork.GroupCipherMask.CCMP;
616                    break;
617                case WifiConfiguration.GroupCipher.GTK_NOT_USED:
618                    mask |= ISupplicantStaNetwork.GroupCipherMask.GTK_NOT_USED;
619                    break;
620                default:
621                    throw new IllegalArgumentException(
622                            "Invalid GroupCipherMask bit in wificonfig: " + bit);
623            }
624        }
625        return mask;
626    };
627
628    private static int wifiConfigurationToSupplicantPairwiseCipherMask(BitSet pairwiseCipherMask) {
629        int mask = 0;
630        for (int bit = pairwiseCipherMask.nextSetBit(0); bit != -1;
631                bit = pairwiseCipherMask.nextSetBit(bit + 1)) {
632            switch (bit) {
633                case WifiConfiguration.PairwiseCipher.NONE:
634                    mask |= ISupplicantStaNetwork.PairwiseCipherMask.NONE;
635                    break;
636                case WifiConfiguration.PairwiseCipher.TKIP:
637                    mask |= ISupplicantStaNetwork.PairwiseCipherMask.TKIP;
638                    break;
639                case WifiConfiguration.PairwiseCipher.CCMP:
640                    mask |= ISupplicantStaNetwork.PairwiseCipherMask.CCMP;
641                    break;
642                default:
643                    throw new IllegalArgumentException(
644                            "Invalid pairwiseCipherMask bit in wificonfig: " + bit);
645            }
646        }
647        return mask;
648    };
649
650    private static int supplicantToWifiConfigurationEapMethod(int value) {
651        switch (value) {
652            case ISupplicantStaNetwork.EapMethod.PEAP:
653                return WifiEnterpriseConfig.Eap.PEAP;
654            case ISupplicantStaNetwork.EapMethod.TLS:
655                return WifiEnterpriseConfig.Eap.TLS;
656            case ISupplicantStaNetwork.EapMethod.TTLS:
657                return WifiEnterpriseConfig.Eap.TTLS;
658            case ISupplicantStaNetwork.EapMethod.PWD:
659                return WifiEnterpriseConfig.Eap.PWD;
660            case ISupplicantStaNetwork.EapMethod.SIM:
661                return WifiEnterpriseConfig.Eap.SIM;
662            case ISupplicantStaNetwork.EapMethod.AKA:
663                return WifiEnterpriseConfig.Eap.AKA;
664            case ISupplicantStaNetwork.EapMethod.AKA_PRIME:
665                return WifiEnterpriseConfig.Eap.AKA_PRIME;
666            case ISupplicantStaNetwork.EapMethod.WFA_UNAUTH_TLS:
667                return WifiEnterpriseConfig.Eap.UNAUTH_TLS;
668            // WifiEnterpriseConfig.Eap.NONE:
669            default:
670                Log.e(TAG, "invalid eap method value from supplicant: " + value);
671                return -1;
672        }
673    };
674
675    private static int supplicantToWifiConfigurationEapPhase2Method(int value) {
676        switch (value) {
677            case ISupplicantStaNetwork.EapPhase2Method.NONE:
678                return WifiEnterpriseConfig.Phase2.NONE;
679            case ISupplicantStaNetwork.EapPhase2Method.PAP:
680                return WifiEnterpriseConfig.Phase2.PAP;
681            case ISupplicantStaNetwork.EapPhase2Method.MSPAP:
682                return WifiEnterpriseConfig.Phase2.MSCHAP;
683            case ISupplicantStaNetwork.EapPhase2Method.MSPAPV2:
684                return WifiEnterpriseConfig.Phase2.MSCHAPV2;
685            case ISupplicantStaNetwork.EapPhase2Method.GTC:
686                return WifiEnterpriseConfig.Phase2.GTC;
687            default:
688                Log.e(TAG, "invalid eap phase2 method value from supplicant: " + value);
689                return -1;
690        }
691    };
692
693    private static int supplicantMaskValueToWifiConfigurationBitSet(int supplicantMask,
694                                                             int supplicantValue, BitSet bitset,
695                                                             int bitSetPosition) {
696        bitset.set(bitSetPosition, (supplicantMask & supplicantValue) == supplicantValue);
697        int modifiedSupplicantMask = supplicantMask & ~supplicantValue;
698        return modifiedSupplicantMask;
699    }
700
701    private static BitSet supplicantToWifiConfigurationKeyMgmtMask(int mask) {
702        BitSet bitset = new BitSet();
703        mask = supplicantMaskValueToWifiConfigurationBitSet(
704                mask, ISupplicantStaNetwork.KeyMgmtMask.NONE, bitset,
705                WifiConfiguration.KeyMgmt.NONE);
706        mask = supplicantMaskValueToWifiConfigurationBitSet(
707                mask, ISupplicantStaNetwork.KeyMgmtMask.WPA_PSK, bitset,
708                WifiConfiguration.KeyMgmt.WPA_PSK);
709        mask = supplicantMaskValueToWifiConfigurationBitSet(
710                mask, ISupplicantStaNetwork.KeyMgmtMask.WPA_EAP, bitset,
711                WifiConfiguration.KeyMgmt.WPA_EAP);
712        mask = supplicantMaskValueToWifiConfigurationBitSet(
713                mask, ISupplicantStaNetwork.KeyMgmtMask.IEEE8021X, bitset,
714                WifiConfiguration.KeyMgmt.IEEE8021X);
715        mask = supplicantMaskValueToWifiConfigurationBitSet(
716                mask, ISupplicantStaNetwork.KeyMgmtMask.OSEN, bitset,
717                WifiConfiguration.KeyMgmt.OSEN);
718        mask = supplicantMaskValueToWifiConfigurationBitSet(
719                mask, ISupplicantStaNetwork.KeyMgmtMask.FT_PSK, bitset,
720                WifiConfiguration.KeyMgmt.FT_PSK);
721        mask = supplicantMaskValueToWifiConfigurationBitSet(
722                mask, ISupplicantStaNetwork.KeyMgmtMask.FT_EAP, bitset,
723                WifiConfiguration.KeyMgmt.FT_EAP);
724        if (mask != 0) {
725            throw new IllegalArgumentException(
726                    "invalid key mgmt mask from supplicant: " + mask);
727        }
728        return bitset;
729    }
730
731    private static BitSet supplicantToWifiConfigurationProtoMask(int mask) {
732        BitSet bitset = new BitSet();
733        mask = supplicantMaskValueToWifiConfigurationBitSet(
734                mask, ISupplicantStaNetwork.ProtoMask.WPA, bitset,
735                WifiConfiguration.Protocol.WPA);
736        mask = supplicantMaskValueToWifiConfigurationBitSet(
737                mask, ISupplicantStaNetwork.ProtoMask.RSN, bitset,
738                WifiConfiguration.Protocol.RSN);
739        mask = supplicantMaskValueToWifiConfigurationBitSet(
740                mask, ISupplicantStaNetwork.ProtoMask.OSEN, bitset,
741                WifiConfiguration.Protocol.OSEN);
742        if (mask != 0) {
743            throw new IllegalArgumentException(
744                    "invalid proto mask from supplicant: " + mask);
745        }
746        return bitset;
747    };
748
749    private static BitSet supplicantToWifiConfigurationAuthAlgMask(int mask) {
750        BitSet bitset = new BitSet();
751        mask = supplicantMaskValueToWifiConfigurationBitSet(
752                mask, ISupplicantStaNetwork.AuthAlgMask.OPEN, bitset,
753                WifiConfiguration.AuthAlgorithm.OPEN);
754        mask = supplicantMaskValueToWifiConfigurationBitSet(
755                mask, ISupplicantStaNetwork.AuthAlgMask.SHARED, bitset,
756                WifiConfiguration.AuthAlgorithm.SHARED);
757        mask = supplicantMaskValueToWifiConfigurationBitSet(
758                mask, ISupplicantStaNetwork.AuthAlgMask.LEAP, bitset,
759                WifiConfiguration.AuthAlgorithm.LEAP);
760        if (mask != 0) {
761            throw new IllegalArgumentException(
762                    "invalid auth alg mask from supplicant: " + mask);
763        }
764        return bitset;
765    };
766
767    private static BitSet supplicantToWifiConfigurationGroupCipherMask(int mask) {
768        BitSet bitset = new BitSet();
769        mask = supplicantMaskValueToWifiConfigurationBitSet(
770                mask, ISupplicantStaNetwork.GroupCipherMask.WEP40, bitset,
771                WifiConfiguration.GroupCipher.WEP40);
772        mask = supplicantMaskValueToWifiConfigurationBitSet(
773                mask, ISupplicantStaNetwork.GroupCipherMask.WEP104, bitset,
774                WifiConfiguration.GroupCipher.WEP104);
775        mask = supplicantMaskValueToWifiConfigurationBitSet(
776                mask, ISupplicantStaNetwork.GroupCipherMask.TKIP, bitset,
777                WifiConfiguration.GroupCipher.TKIP);
778        mask = supplicantMaskValueToWifiConfigurationBitSet(
779                mask, ISupplicantStaNetwork.GroupCipherMask.CCMP, bitset,
780                WifiConfiguration.GroupCipher.CCMP);
781        mask = supplicantMaskValueToWifiConfigurationBitSet(
782                mask, ISupplicantStaNetwork.GroupCipherMask.GTK_NOT_USED, bitset,
783                WifiConfiguration.GroupCipher.GTK_NOT_USED);
784        if (mask != 0) {
785            throw new IllegalArgumentException(
786                    "invalid group cipher mask from supplicant: " + mask);
787        }
788        return bitset;
789    };
790
791    private static BitSet supplicantToWifiConfigurationPairwiseCipherMask(int mask) {
792        BitSet bitset = new BitSet();
793        mask = supplicantMaskValueToWifiConfigurationBitSet(
794                mask, ISupplicantStaNetwork.PairwiseCipherMask.NONE, bitset,
795                WifiConfiguration.PairwiseCipher.NONE);
796        mask = supplicantMaskValueToWifiConfigurationBitSet(
797                mask, ISupplicantStaNetwork.PairwiseCipherMask.TKIP, bitset,
798                WifiConfiguration.PairwiseCipher.TKIP);
799        mask = supplicantMaskValueToWifiConfigurationBitSet(
800                mask, ISupplicantStaNetwork.PairwiseCipherMask.CCMP, bitset,
801                WifiConfiguration.PairwiseCipher.CCMP);
802        if (mask != 0) {
803            throw new IllegalArgumentException(
804                    "invalid pairwise cipher mask from supplicant: " + mask);
805        }
806        return bitset;
807    };
808
809    private static int wifiConfigurationToSupplicantEapMethod(int value) {
810        switch (value) {
811            case WifiEnterpriseConfig.Eap.PEAP:
812                return ISupplicantStaNetwork.EapMethod.PEAP;
813            case WifiEnterpriseConfig.Eap.TLS:
814                return ISupplicantStaNetwork.EapMethod.TLS;
815            case WifiEnterpriseConfig.Eap.TTLS:
816                return ISupplicantStaNetwork.EapMethod.TTLS;
817            case WifiEnterpriseConfig.Eap.PWD:
818                return ISupplicantStaNetwork.EapMethod.PWD;
819            case WifiEnterpriseConfig.Eap.SIM:
820                return ISupplicantStaNetwork.EapMethod.SIM;
821            case WifiEnterpriseConfig.Eap.AKA:
822                return ISupplicantStaNetwork.EapMethod.AKA;
823            case WifiEnterpriseConfig.Eap.AKA_PRIME:
824                return ISupplicantStaNetwork.EapMethod.AKA_PRIME;
825            case WifiEnterpriseConfig.Eap.UNAUTH_TLS:
826                return ISupplicantStaNetwork.EapMethod.WFA_UNAUTH_TLS;
827            // WifiEnterpriseConfig.Eap.NONE:
828            default:
829                Log.e(TAG, "invalid eap method value from WifiConfiguration: " + value);
830                return -1;
831        }
832    };
833
834    private static int wifiConfigurationToSupplicantEapPhase2Method(int value) {
835        switch (value) {
836            case WifiEnterpriseConfig.Phase2.NONE:
837                return ISupplicantStaNetwork.EapPhase2Method.NONE;
838            case WifiEnterpriseConfig.Phase2.PAP:
839                return ISupplicantStaNetwork.EapPhase2Method.PAP;
840            case WifiEnterpriseConfig.Phase2.MSCHAP:
841                return ISupplicantStaNetwork.EapPhase2Method.MSPAP;
842            case WifiEnterpriseConfig.Phase2.MSCHAPV2:
843                return ISupplicantStaNetwork.EapPhase2Method.MSPAPV2;
844            case WifiEnterpriseConfig.Phase2.GTC:
845                return ISupplicantStaNetwork.EapPhase2Method.GTC;
846            default:
847                Log.e(TAG, "invalid eap phase2 method value from WifiConfiguration: " + value);
848                return -1;
849        }
850    };
851
852    /** See ISupplicantNetwork.hal for documentation */
853    public boolean getId() {
854        synchronized (mLock) {
855            final String methodStr = "getId";
856            if (DBG) Log.i(TAG, methodStr);
857            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
858            try {
859                MutableBoolean statusOk = new MutableBoolean(false);
860                mISupplicantStaNetwork.getId((SupplicantStatus status, int idValue) -> {
861                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
862                    if (statusOk.value) {
863                        this.mNetworkId = idValue;
864                    } else {
865                        logFailureStatus(status, methodStr);
866                    }
867                });
868                return statusOk.value;
869            } catch (RemoteException e) {
870                handleRemoteException(e, methodStr);
871                return false;
872            }
873        }
874    }
875
876    /** See ISupplicantNetwork.hal for documentation */
877    private boolean getInterfaceName() {
878        synchronized (mLock) {
879            final String methodStr = "getInterfaceName";
880            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
881            try {
882                MutableBoolean statusOk = new MutableBoolean(false);
883                mISupplicantStaNetwork.getInterfaceName((SupplicantStatus status,
884                        String nameValue) -> {
885                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
886                    if (statusOk.value) {
887                        this.mIfaceName = nameValue;
888                    } else {
889                        logFailureStatus(status, methodStr);
890                    }
891                });
892                return statusOk.value;
893            } catch (RemoteException e) {
894                handleRemoteException(e, methodStr);
895                return false;
896            }
897        }
898    }
899
900    /** See ISupplicantStaNetwork.hal for documentation */
901    private boolean registerCallback(ISupplicantStaNetworkCallback callback) {
902        synchronized (mLock) {
903            final String methodStr = "registerCallback";
904            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
905            try {
906                SupplicantStatus status =  mISupplicantStaNetwork.registerCallback(callback);
907                return checkStatusAndLogFailure(status, methodStr);
908            } catch (RemoteException e) {
909                handleRemoteException(e, methodStr);
910                return false;
911            }
912        }
913    }
914
915    /** See ISupplicantStaNetwork.hal for documentation */
916    private boolean setSsid(java.util.ArrayList<Byte> ssid) {
917        synchronized (mLock) {
918            final String methodStr = "setSsid";
919            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
920            try {
921                SupplicantStatus status =  mISupplicantStaNetwork.setSsid(ssid);
922                return checkStatusAndLogFailure(status, methodStr);
923            } catch (RemoteException e) {
924                handleRemoteException(e, methodStr);
925                return false;
926            }
927        }
928    }
929    /** See ISupplicantStaNetwork.hal for documentation */
930    private boolean setBssid(byte[/* 6 */] bssid) {
931        synchronized (mLock) {
932            final String methodStr = "setBssid";
933            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
934            try {
935                SupplicantStatus status =  mISupplicantStaNetwork.setBssid(bssid);
936                return checkStatusAndLogFailure(status, methodStr);
937            } catch (RemoteException e) {
938                handleRemoteException(e, methodStr);
939                return false;
940            }
941        }
942    }
943    /** See ISupplicantStaNetwork.hal for documentation */
944    private boolean setScanSsid(boolean enable) {
945        synchronized (mLock) {
946            final String methodStr = "setScanSsid";
947            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
948            try {
949                SupplicantStatus status =  mISupplicantStaNetwork.setScanSsid(enable);
950                return checkStatusAndLogFailure(status, methodStr);
951            } catch (RemoteException e) {
952                handleRemoteException(e, methodStr);
953                return false;
954            }
955        }
956    }
957    /** See ISupplicantStaNetwork.hal for documentation */
958    private boolean setKeyMgmt(int keyMgmtMask) {
959        synchronized (mLock) {
960            final String methodStr = "setKeyMgmt";
961            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
962            try {
963                SupplicantStatus status =  mISupplicantStaNetwork.setKeyMgmt(keyMgmtMask);
964                return checkStatusAndLogFailure(status, methodStr);
965            } catch (RemoteException e) {
966                handleRemoteException(e, methodStr);
967                return false;
968            }
969        }
970    }
971    /** See ISupplicantStaNetwork.hal for documentation */
972    private boolean setProto(int protoMask) {
973        synchronized (mLock) {
974            final String methodStr = "setProto";
975            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
976            try {
977                SupplicantStatus status =  mISupplicantStaNetwork.setProto(protoMask);
978                return checkStatusAndLogFailure(status, methodStr);
979            } catch (RemoteException e) {
980                handleRemoteException(e, methodStr);
981                return false;
982            }
983        }
984    }
985    /** See ISupplicantStaNetwork.hal for documentation */
986    private boolean setAuthAlg(int authAlgMask) {
987        synchronized (mLock) {
988            final String methodStr = "setAuthAlg";
989            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
990            try {
991                SupplicantStatus status =  mISupplicantStaNetwork.setAuthAlg(authAlgMask);
992                return checkStatusAndLogFailure(status, methodStr);
993            } catch (RemoteException e) {
994                handleRemoteException(e, methodStr);
995                return false;
996            }
997        }
998    }
999    /** See ISupplicantStaNetwork.hal for documentation */
1000    private boolean setGroupCipher(int groupCipherMask) {
1001        synchronized (mLock) {
1002            final String methodStr = "setGroupCipher";
1003            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1004            try {
1005                SupplicantStatus status =  mISupplicantStaNetwork.setGroupCipher(groupCipherMask);
1006                return checkStatusAndLogFailure(status, methodStr);
1007            } catch (RemoteException e) {
1008                handleRemoteException(e, methodStr);
1009                return false;
1010            }
1011        }
1012    }
1013    /** See ISupplicantStaNetwork.hal for documentation */
1014    private boolean setPairwiseCipher(int pairwiseCipherMask) {
1015        synchronized (mLock) {
1016            final String methodStr = "setPairwiseCipher";
1017            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1018            try {
1019                SupplicantStatus status =
1020                        mISupplicantStaNetwork.setPairwiseCipher(pairwiseCipherMask);
1021                return checkStatusAndLogFailure(status, methodStr);
1022            } catch (RemoteException e) {
1023                handleRemoteException(e, methodStr);
1024                return false;
1025            }
1026        }
1027    }
1028    /** See ISupplicantStaNetwork.hal for documentation */
1029    private boolean setPskPassphrase(String psk) {
1030        synchronized (mLock) {
1031            final String methodStr = "setPskPassphrase";
1032            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1033            try {
1034                SupplicantStatus status =  mISupplicantStaNetwork.setPskPassphrase(psk);
1035                return checkStatusAndLogFailure(status, methodStr);
1036            } catch (RemoteException e) {
1037                handleRemoteException(e, methodStr);
1038                return false;
1039            }
1040        }
1041    }
1042    /** See ISupplicantStaNetwork.hal for documentation */
1043    private boolean setWepKey(int keyIdx, java.util.ArrayList<Byte> wepKey) {
1044        synchronized (mLock) {
1045            final String methodStr = "setWepKey";
1046            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1047            try {
1048                SupplicantStatus status =  mISupplicantStaNetwork.setWepKey(keyIdx, wepKey);
1049                return checkStatusAndLogFailure(status, methodStr);
1050            } catch (RemoteException e) {
1051                handleRemoteException(e, methodStr);
1052                return false;
1053            }
1054        }
1055    }
1056    /** See ISupplicantStaNetwork.hal for documentation */
1057    private boolean setWepTxKeyIdx(int keyIdx) {
1058        synchronized (mLock) {
1059            final String methodStr = "setWepTxKeyIdx";
1060            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1061            try {
1062                SupplicantStatus status =  mISupplicantStaNetwork.setWepTxKeyIdx(keyIdx);
1063                return checkStatusAndLogFailure(status, methodStr);
1064            } catch (RemoteException e) {
1065                handleRemoteException(e, methodStr);
1066                return false;
1067            }
1068        }
1069    }
1070    /** See ISupplicantStaNetwork.hal for documentation */
1071    private boolean setRequirePmf(boolean enable) {
1072        synchronized (mLock) {
1073            final String methodStr = "setRequirePmf";
1074            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1075            try {
1076                SupplicantStatus status =  mISupplicantStaNetwork.setRequirePmf(enable);
1077                return checkStatusAndLogFailure(status, methodStr);
1078            } catch (RemoteException e) {
1079                handleRemoteException(e, methodStr);
1080                return false;
1081            }
1082        }
1083    }
1084    /** See ISupplicantStaNetwork.hal for documentation */
1085    private boolean setUpdateIdentifier(int identifier) {
1086        synchronized (mLock) {
1087            final String methodStr = "setUpdateIdentifier";
1088            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1089            try {
1090                SupplicantStatus status =  mISupplicantStaNetwork.setUpdateIdentifier(identifier);
1091                return checkStatusAndLogFailure(status, methodStr);
1092            } catch (RemoteException e) {
1093                handleRemoteException(e, methodStr);
1094                return false;
1095            }
1096        }
1097    }
1098    /** See ISupplicantStaNetwork.hal for documentation */
1099    private boolean setEapMethod(int method) {
1100        synchronized (mLock) {
1101            final String methodStr = "setEapMethod";
1102            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1103            try {
1104                SupplicantStatus status =  mISupplicantStaNetwork.setEapMethod(method);
1105                return checkStatusAndLogFailure(status, methodStr);
1106            } catch (RemoteException e) {
1107                handleRemoteException(e, methodStr);
1108                return false;
1109            }
1110        }
1111    }
1112    /** See ISupplicantStaNetwork.hal for documentation */
1113    private boolean setEapPhase2Method(int method) {
1114        synchronized (mLock) {
1115            final String methodStr = "setEapPhase2Method";
1116            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1117            try {
1118                SupplicantStatus status =  mISupplicantStaNetwork.setEapPhase2Method(method);
1119                return checkStatusAndLogFailure(status, methodStr);
1120            } catch (RemoteException e) {
1121                handleRemoteException(e, methodStr);
1122                return false;
1123            }
1124        }
1125    }
1126    /** See ISupplicantStaNetwork.hal for documentation */
1127    private boolean setEapIdentity(java.util.ArrayList<Byte> identity) {
1128        synchronized (mLock) {
1129            final String methodStr = "setEapIdentity";
1130            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1131            try {
1132                SupplicantStatus status =  mISupplicantStaNetwork.setEapIdentity(identity);
1133                return checkStatusAndLogFailure(status, methodStr);
1134            } catch (RemoteException e) {
1135                handleRemoteException(e, methodStr);
1136                return false;
1137            }
1138        }
1139    }
1140    /** See ISupplicantStaNetwork.hal for documentation */
1141    private boolean setEapAnonymousIdentity(java.util.ArrayList<Byte> identity) {
1142        synchronized (mLock) {
1143            final String methodStr = "setEapAnonymousIdentity";
1144            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1145            try {
1146                SupplicantStatus status =  mISupplicantStaNetwork.setEapAnonymousIdentity(identity);
1147                return checkStatusAndLogFailure(status, methodStr);
1148            } catch (RemoteException e) {
1149                handleRemoteException(e, methodStr);
1150                return false;
1151            }
1152        }
1153    }
1154    /** See ISupplicantStaNetwork.hal for documentation */
1155    private boolean setEapPassword(java.util.ArrayList<Byte> password) {
1156        synchronized (mLock) {
1157            final String methodStr = "setEapPassword";
1158            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1159            try {
1160                SupplicantStatus status =  mISupplicantStaNetwork.setEapPassword(password);
1161                return checkStatusAndLogFailure(status, methodStr);
1162            } catch (RemoteException e) {
1163                handleRemoteException(e, methodStr);
1164                return false;
1165            }
1166        }
1167    }
1168    /** See ISupplicantStaNetwork.hal for documentation */
1169    private boolean setEapCACert(String path) {
1170        synchronized (mLock) {
1171            final String methodStr = "setEapCACert";
1172            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1173            try {
1174                SupplicantStatus status =  mISupplicantStaNetwork.setEapCACert(path);
1175                return checkStatusAndLogFailure(status, methodStr);
1176            } catch (RemoteException e) {
1177                handleRemoteException(e, methodStr);
1178                return false;
1179            }
1180        }
1181    }
1182    /** See ISupplicantStaNetwork.hal for documentation */
1183    private boolean setEapCAPath(String path) {
1184        synchronized (mLock) {
1185            final String methodStr = "setEapCAPath";
1186            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1187            try {
1188                SupplicantStatus status =  mISupplicantStaNetwork.setEapCAPath(path);
1189                return checkStatusAndLogFailure(status, methodStr);
1190            } catch (RemoteException e) {
1191                handleRemoteException(e, methodStr);
1192                return false;
1193            }
1194        }
1195    }
1196    /** See ISupplicantStaNetwork.hal for documentation */
1197    private boolean setEapClientCert(String path) {
1198        synchronized (mLock) {
1199            final String methodStr = "setEapClientCert";
1200            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1201            try {
1202                SupplicantStatus status =  mISupplicantStaNetwork.setEapClientCert(path);
1203                return checkStatusAndLogFailure(status, methodStr);
1204            } catch (RemoteException e) {
1205                handleRemoteException(e, methodStr);
1206                return false;
1207            }
1208        }
1209    }
1210    /** See ISupplicantStaNetwork.hal for documentation */
1211    private boolean setEapPrivateKey(String path) {
1212        synchronized (mLock) {
1213            final String methodStr = "setEapPrivateKey";
1214            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1215            try {
1216                SupplicantStatus status =  mISupplicantStaNetwork.setEapPrivateKey(path);
1217                return checkStatusAndLogFailure(status, methodStr);
1218            } catch (RemoteException e) {
1219                handleRemoteException(e, methodStr);
1220                return false;
1221            }
1222        }
1223    }
1224    /** See ISupplicantStaNetwork.hal for documentation */
1225    private boolean setEapSubjectMatch(String match) {
1226        synchronized (mLock) {
1227            final String methodStr = "setEapSubjectMatch";
1228            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1229            try {
1230                SupplicantStatus status =  mISupplicantStaNetwork.setEapSubjectMatch(match);
1231                return checkStatusAndLogFailure(status, methodStr);
1232            } catch (RemoteException e) {
1233                handleRemoteException(e, methodStr);
1234                return false;
1235            }
1236        }
1237    }
1238    /** See ISupplicantStaNetwork.hal for documentation */
1239    private boolean setEapAltSubjectMatch(String match) {
1240        synchronized (mLock) {
1241            final String methodStr = "setEapAltSubjectMatch";
1242            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1243            try {
1244                SupplicantStatus status =  mISupplicantStaNetwork.setEapAltSubjectMatch(match);
1245                return checkStatusAndLogFailure(status, methodStr);
1246            } catch (RemoteException e) {
1247                handleRemoteException(e, methodStr);
1248                return false;
1249            }
1250        }
1251    }
1252    /** See ISupplicantStaNetwork.hal for documentation */
1253    private boolean setEapEngine(boolean enable) {
1254        synchronized (mLock) {
1255            final String methodStr = "setEapEngine";
1256            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1257            try {
1258                SupplicantStatus status =  mISupplicantStaNetwork.setEapEngine(enable);
1259                return checkStatusAndLogFailure(status, methodStr);
1260            } catch (RemoteException e) {
1261                handleRemoteException(e, methodStr);
1262                return false;
1263            }
1264        }
1265    }
1266    /** See ISupplicantStaNetwork.hal for documentation */
1267    private boolean setEapEngineID(String id) {
1268        synchronized (mLock) {
1269            final String methodStr = "setEapEngineID";
1270            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1271            try {
1272                SupplicantStatus status =  mISupplicantStaNetwork.setEapEngineID(id);
1273                return checkStatusAndLogFailure(status, methodStr);
1274            } catch (RemoteException e) {
1275                handleRemoteException(e, methodStr);
1276                return false;
1277            }
1278        }
1279    }
1280    /** See ISupplicantStaNetwork.hal for documentation */
1281    private boolean setEapDomainSuffixMatch(String match) {
1282        synchronized (mLock) {
1283            final String methodStr = "setEapDomainSuffixMatch";
1284            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1285            try {
1286                SupplicantStatus status =  mISupplicantStaNetwork.setEapDomainSuffixMatch(match);
1287                return checkStatusAndLogFailure(status, methodStr);
1288            } catch (RemoteException e) {
1289                handleRemoteException(e, methodStr);
1290                return false;
1291            }
1292        }
1293    }
1294    /** See ISupplicantStaNetwork.hal for documentation */
1295    private boolean setEapProactiveKeyCaching(boolean enable) {
1296        synchronized (mLock) {
1297            final String methodStr = "setEapProactiveKeyCaching";
1298            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1299            try {
1300                SupplicantStatus status =  mISupplicantStaNetwork.setProactiveKeyCaching(enable);
1301                return checkStatusAndLogFailure(status, methodStr);
1302            } catch (RemoteException e) {
1303                handleRemoteException(e, methodStr);
1304                return false;
1305            }
1306        }
1307    }
1308    /** See ISupplicantStaNetwork.hal for documentation */
1309    private boolean setIdStr(String idString) {
1310        synchronized (mLock) {
1311            final String methodStr = "setIdStr";
1312            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1313            try {
1314                SupplicantStatus status =  mISupplicantStaNetwork.setIdStr(idString);
1315                return checkStatusAndLogFailure(status, methodStr);
1316            } catch (RemoteException e) {
1317                handleRemoteException(e, methodStr);
1318                return false;
1319            }
1320        }
1321    }
1322    /** See ISupplicantStaNetwork.hal for documentation */
1323    private boolean getSsid() {
1324        synchronized (mLock) {
1325            final String methodStr = "getSsid";
1326            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1327            try {
1328                MutableBoolean statusOk = new MutableBoolean(false);
1329                mISupplicantStaNetwork.getSsid((SupplicantStatus status,
1330                        java.util.ArrayList<Byte> ssidValue) -> {
1331                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1332                    if (statusOk.value) {
1333                        this.mSsid = ssidValue;
1334                    } else {
1335                        logFailureStatus(status, methodStr);
1336                    }
1337                });
1338                return statusOk.value;
1339            } catch (RemoteException e) {
1340                handleRemoteException(e, methodStr);
1341                return false;
1342            }
1343        }
1344    }
1345    /** See ISupplicantStaNetwork.hal for documentation */
1346    private boolean getBssid() {
1347        synchronized (mLock) {
1348            final String methodStr = "getBssid";
1349            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1350            try {
1351                MutableBoolean statusOk = new MutableBoolean(false);
1352                mISupplicantStaNetwork.getBssid((SupplicantStatus status,
1353                        byte[/* 6 */] bssidValue) -> {
1354                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1355                    if (statusOk.value) {
1356                        this.mBssid = bssidValue;
1357                    } else {
1358                        logFailureStatus(status, methodStr);
1359                    }
1360                });
1361                return statusOk.value;
1362            } catch (RemoteException e) {
1363                handleRemoteException(e, methodStr);
1364                return false;
1365            }
1366        }
1367    }
1368    /** See ISupplicantStaNetwork.hal for documentation */
1369    private boolean getScanSsid() {
1370        synchronized (mLock) {
1371            final String methodStr = "getScanSsid";
1372            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1373            try {
1374                MutableBoolean statusOk = new MutableBoolean(false);
1375                mISupplicantStaNetwork.getScanSsid((SupplicantStatus status,
1376                        boolean enabledValue) -> {
1377                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1378                    if (statusOk.value) {
1379                        this.mScanSsid = enabledValue;
1380                    } else {
1381                        logFailureStatus(status, methodStr);
1382                    }
1383                });
1384                return statusOk.value;
1385            } catch (RemoteException e) {
1386                handleRemoteException(e, methodStr);
1387                return false;
1388            }
1389        }
1390    }
1391    /** See ISupplicantStaNetwork.hal for documentation */
1392    private boolean getKeyMgmt() {
1393        synchronized (mLock) {
1394            final String methodStr = "getKeyMgmt";
1395            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1396            try {
1397                MutableBoolean statusOk = new MutableBoolean(false);
1398                mISupplicantStaNetwork.getKeyMgmt((SupplicantStatus status,
1399                        int keyMgmtMaskValue) -> {
1400                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1401                    if (statusOk.value) {
1402                        this.mKeyMgmtMask = keyMgmtMaskValue;
1403                    } else {
1404                        logFailureStatus(status, methodStr);
1405                    }
1406                });
1407                return statusOk.value;
1408            } catch (RemoteException e) {
1409                handleRemoteException(e, methodStr);
1410                return false;
1411            }
1412        }
1413    }
1414    /** See ISupplicantStaNetwork.hal for documentation */
1415    private boolean getProto() {
1416        synchronized (mLock) {
1417            final String methodStr = "getProto";
1418            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1419            try {
1420                MutableBoolean statusOk = new MutableBoolean(false);
1421                mISupplicantStaNetwork.getProto((SupplicantStatus status, int protoMaskValue) -> {
1422                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1423                    if (statusOk.value) {
1424                        this.mProtoMask = protoMaskValue;
1425                    } else {
1426                        logFailureStatus(status, methodStr);
1427                    }
1428                });
1429                return statusOk.value;
1430            } catch (RemoteException e) {
1431                handleRemoteException(e, methodStr);
1432                return false;
1433            }
1434        }
1435    }
1436    /** See ISupplicantStaNetwork.hal for documentation */
1437    private boolean getAuthAlg() {
1438        synchronized (mLock) {
1439            final String methodStr = "getAuthAlg";
1440            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1441            try {
1442                MutableBoolean statusOk = new MutableBoolean(false);
1443                mISupplicantStaNetwork.getAuthAlg((SupplicantStatus status,
1444                        int authAlgMaskValue) -> {
1445                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1446                    if (statusOk.value) {
1447                        this.mAuthAlgMask = authAlgMaskValue;
1448                    } else {
1449                        logFailureStatus(status, methodStr);
1450                    }
1451                });
1452                return statusOk.value;
1453            } catch (RemoteException e) {
1454                handleRemoteException(e, methodStr);
1455                return false;
1456            }
1457        }
1458    }
1459    /** See ISupplicantStaNetwork.hal for documentation */
1460    private boolean getGroupCipher() {
1461        synchronized (mLock) {
1462            final String methodStr = "getGroupCipher";
1463            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1464            try {
1465                MutableBoolean statusOk = new MutableBoolean(false);
1466                mISupplicantStaNetwork.getGroupCipher((SupplicantStatus status,
1467                        int groupCipherMaskValue) -> {
1468                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1469                    if (statusOk.value) {
1470                        this.mGroupCipherMask = groupCipherMaskValue;
1471                    } else {
1472                        logFailureStatus(status, methodStr);
1473                    }
1474                });
1475                return statusOk.value;
1476            } catch (RemoteException e) {
1477                handleRemoteException(e, methodStr);
1478                return false;
1479            }
1480        }
1481    }
1482    /** See ISupplicantStaNetwork.hal for documentation */
1483    private boolean getPairwiseCipher() {
1484        synchronized (mLock) {
1485            final String methodStr = "getPairwiseCipher";
1486            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1487            try {
1488                MutableBoolean statusOk = new MutableBoolean(false);
1489                mISupplicantStaNetwork.getPairwiseCipher((SupplicantStatus status,
1490                        int pairwiseCipherMaskValue) -> {
1491                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1492                    if (statusOk.value) {
1493                        this.mPairwiseCipherMask = pairwiseCipherMaskValue;
1494                    } else {
1495                        logFailureStatus(status, methodStr);
1496                    }
1497                });
1498                return statusOk.value;
1499            } catch (RemoteException e) {
1500                handleRemoteException(e, methodStr);
1501                return false;
1502            }
1503        }
1504    }
1505    /** See ISupplicantStaNetwork.hal for documentation */
1506    private boolean getPskPassphrase() {
1507        synchronized (mLock) {
1508            final String methodStr = "getPskPassphrase";
1509            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1510            try {
1511                MutableBoolean statusOk = new MutableBoolean(false);
1512                mISupplicantStaNetwork.getPskPassphrase((SupplicantStatus status,
1513                        String pskValue) -> {
1514                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1515                    if (statusOk.value) {
1516                        this.mPskPassphrase = pskValue;
1517                    } else {
1518                        logFailureStatus(status, methodStr);
1519                    }
1520                });
1521                return statusOk.value;
1522            } catch (RemoteException e) {
1523                handleRemoteException(e, methodStr);
1524                return false;
1525            }
1526        }
1527    }
1528    /** See ISupplicantStaNetwork.hal for documentation */
1529    private boolean getWepKey(int keyIdx) {
1530        synchronized (mLock) {
1531            final String methodStr = "keyIdx";
1532            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1533            try {
1534                MutableBoolean statusOk = new MutableBoolean(false);
1535                mISupplicantStaNetwork.getWepKey(keyIdx, (SupplicantStatus status,
1536                        java.util.ArrayList<Byte> wepKeyValue) -> {
1537                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1538                    if (statusOk.value) {
1539                        this.mWepKey = wepKeyValue;
1540                    } else {
1541                        Log.e(TAG, methodStr + ",  failed: " + status.debugMessage);
1542                    }
1543                });
1544                return statusOk.value;
1545            } catch (RemoteException e) {
1546                handleRemoteException(e, methodStr);
1547                return false;
1548            }
1549        }
1550    }
1551    /** See ISupplicantStaNetwork.hal for documentation */
1552    private boolean getWepTxKeyIdx() {
1553        synchronized (mLock) {
1554            final String methodStr = "getWepTxKeyIdx";
1555            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1556            try {
1557                MutableBoolean statusOk = new MutableBoolean(false);
1558                mISupplicantStaNetwork.getWepTxKeyIdx((SupplicantStatus status,
1559                        int keyIdxValue) -> {
1560                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1561                    if (statusOk.value) {
1562                        this.mWepTxKeyIdx = keyIdxValue;
1563                    } else {
1564                        logFailureStatus(status, methodStr);
1565                    }
1566                });
1567                return statusOk.value;
1568            } catch (RemoteException e) {
1569                handleRemoteException(e, methodStr);
1570                return false;
1571            }
1572        }
1573    }
1574    /** See ISupplicantStaNetwork.hal for documentation */
1575    private boolean getRequirePmf() {
1576        synchronized (mLock) {
1577            final String methodStr = "getRequirePmf";
1578            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1579            try {
1580                MutableBoolean statusOk = new MutableBoolean(false);
1581                mISupplicantStaNetwork.getRequirePmf((SupplicantStatus status,
1582                        boolean enabledValue) -> {
1583                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1584                    if (statusOk.value) {
1585                        this.mRequirePmf = enabledValue;
1586                    } else {
1587                        logFailureStatus(status, methodStr);
1588                    }
1589                });
1590                return statusOk.value;
1591            } catch (RemoteException e) {
1592                handleRemoteException(e, methodStr);
1593                return false;
1594            }
1595        }
1596    }
1597    /** See ISupplicantStaNetwork.hal for documentation */
1598    private boolean getEapMethod() {
1599        synchronized (mLock) {
1600            final String methodStr = "getEapMethod";
1601            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1602            try {
1603                MutableBoolean statusOk = new MutableBoolean(false);
1604                mISupplicantStaNetwork.getEapMethod((SupplicantStatus status,
1605                        int methodValue) -> {
1606                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1607                    if (statusOk.value) {
1608                        this.mEapMethod = methodValue;
1609                    } else {
1610                        logFailureStatus(status, methodStr);
1611                    }
1612                });
1613                return statusOk.value;
1614            } catch (RemoteException e) {
1615                handleRemoteException(e, methodStr);
1616                return false;
1617            }
1618        }
1619    }
1620    /** See ISupplicantStaNetwork.hal for documentation */
1621    private boolean getEapPhase2Method() {
1622        synchronized (mLock) {
1623            final String methodStr = "getEapPhase2Method";
1624            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1625            try {
1626                MutableBoolean statusOk = new MutableBoolean(false);
1627                mISupplicantStaNetwork.getEapPhase2Method((SupplicantStatus status,
1628                        int methodValue) -> {
1629                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1630                    if (statusOk.value) {
1631                        this.mEapPhase2Method = methodValue;
1632                    } else {
1633                        logFailureStatus(status, methodStr);
1634                    }
1635                });
1636                return statusOk.value;
1637            } catch (RemoteException e) {
1638                handleRemoteException(e, methodStr);
1639                return false;
1640            }
1641        }
1642    }
1643    /** See ISupplicantStaNetwork.hal for documentation */
1644    private boolean getEapIdentity() {
1645        synchronized (mLock) {
1646            final String methodStr = "getEapIdentity";
1647            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1648            try {
1649                MutableBoolean statusOk = new MutableBoolean(false);
1650                mISupplicantStaNetwork.getEapIdentity((SupplicantStatus status,
1651                        ArrayList<Byte> identityValue) -> {
1652                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1653                    if (statusOk.value) {
1654                        this.mEapIdentity = identityValue;
1655                    } else {
1656                        logFailureStatus(status, methodStr);
1657                    }
1658                });
1659                return statusOk.value;
1660            } catch (RemoteException e) {
1661                handleRemoteException(e, methodStr);
1662                return false;
1663            }
1664        }
1665    }
1666    /** See ISupplicantStaNetwork.hal for documentation */
1667    private boolean getEapAnonymousIdentity() {
1668        synchronized (mLock) {
1669            final String methodStr = "getEapAnonymousIdentity";
1670            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1671            try {
1672                MutableBoolean statusOk = new MutableBoolean(false);
1673                mISupplicantStaNetwork.getEapAnonymousIdentity((SupplicantStatus status,
1674                        ArrayList<Byte> identityValue) -> {
1675                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1676                    if (statusOk.value) {
1677                        this.mEapAnonymousIdentity = identityValue;
1678                    } else {
1679                        logFailureStatus(status, methodStr);
1680                    }
1681                });
1682                return statusOk.value;
1683            } catch (RemoteException e) {
1684                handleRemoteException(e, methodStr);
1685                return false;
1686            }
1687        }
1688    }
1689    /** See ISupplicantStaNetwork.hal for documentation */
1690    private boolean getEapPassword() {
1691        synchronized (mLock) {
1692            final String methodStr = "getEapPassword";
1693            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1694            try {
1695                MutableBoolean statusOk = new MutableBoolean(false);
1696                mISupplicantStaNetwork.getEapPassword((SupplicantStatus status,
1697                        ArrayList<Byte> passwordValue) -> {
1698                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1699                    if (statusOk.value) {
1700                        this.mEapPassword = passwordValue;
1701                    } else {
1702                        logFailureStatus(status, methodStr);
1703                    }
1704                });
1705                return statusOk.value;
1706            } catch (RemoteException e) {
1707                handleRemoteException(e, methodStr);
1708                return false;
1709            }
1710        }
1711    }
1712    /** See ISupplicantStaNetwork.hal for documentation */
1713    private boolean getEapCACert() {
1714        synchronized (mLock) {
1715            final String methodStr = "getEapCACert";
1716            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1717            try {
1718                MutableBoolean statusOk = new MutableBoolean(false);
1719                mISupplicantStaNetwork.getEapCACert((SupplicantStatus status, String pathValue) -> {
1720                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1721                    if (statusOk.value) {
1722                        this.mEapCACert = pathValue;
1723                    } else {
1724                        logFailureStatus(status, methodStr);
1725                    }
1726                });
1727                return statusOk.value;
1728            } catch (RemoteException e) {
1729                handleRemoteException(e, methodStr);
1730                return false;
1731            }
1732        }
1733    }
1734    /** See ISupplicantStaNetwork.hal for documentation */
1735    private boolean getEapCAPath() {
1736        synchronized (mLock) {
1737            final String methodStr = "getEapCAPath";
1738            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1739            try {
1740                MutableBoolean statusOk = new MutableBoolean(false);
1741                mISupplicantStaNetwork.getEapCAPath((SupplicantStatus status, String pathValue) -> {
1742                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1743                    if (statusOk.value) {
1744                        this.mEapCAPath = pathValue;
1745                    } else {
1746                        logFailureStatus(status, methodStr);
1747                    }
1748                });
1749                return statusOk.value;
1750            } catch (RemoteException e) {
1751                handleRemoteException(e, methodStr);
1752                return false;
1753            }
1754        }
1755    }
1756    /** See ISupplicantStaNetwork.hal for documentation */
1757    private boolean getEapClientCert() {
1758        synchronized (mLock) {
1759            final String methodStr = "getEapClientCert";
1760            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1761            try {
1762                MutableBoolean statusOk = new MutableBoolean(false);
1763                mISupplicantStaNetwork.getEapClientCert((SupplicantStatus status,
1764                        String pathValue) -> {
1765                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1766                    if (statusOk.value) {
1767                        this.mEapClientCert = pathValue;
1768                    } else {
1769                        logFailureStatus(status, methodStr);
1770                    }
1771                });
1772                return statusOk.value;
1773            } catch (RemoteException e) {
1774                handleRemoteException(e, methodStr);
1775                return false;
1776            }
1777        }
1778    }
1779    /** See ISupplicantStaNetwork.hal for documentation */
1780    private boolean getEapPrivateKey() {
1781        synchronized (mLock) {
1782            final String methodStr = "getEapPrivateKey";
1783            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1784            try {
1785                MutableBoolean statusOk = new MutableBoolean(false);
1786                mISupplicantStaNetwork.getEapPrivateKey((SupplicantStatus status,
1787                        String pathValue) -> {
1788                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1789                    if (statusOk.value) {
1790                        this.mEapPrivateKey = pathValue;
1791                    } else {
1792                        logFailureStatus(status, methodStr);
1793                    }
1794                });
1795                return statusOk.value;
1796            } catch (RemoteException e) {
1797                handleRemoteException(e, methodStr);
1798                return false;
1799            }
1800        }
1801    }
1802    /** See ISupplicantStaNetwork.hal for documentation */
1803    private boolean getEapSubjectMatch() {
1804        synchronized (mLock) {
1805            final String methodStr = "getEapSubjectMatch";
1806            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1807            try {
1808                MutableBoolean statusOk = new MutableBoolean(false);
1809                mISupplicantStaNetwork.getEapSubjectMatch((SupplicantStatus status,
1810                        String matchValue) -> {
1811                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1812                    if (statusOk.value) {
1813                        this.mEapSubjectMatch = matchValue;
1814                    } else {
1815                        logFailureStatus(status, methodStr);
1816                    }
1817                });
1818                return statusOk.value;
1819            } catch (RemoteException e) {
1820                handleRemoteException(e, methodStr);
1821                return false;
1822            }
1823        }
1824    }
1825    /** See ISupplicantStaNetwork.hal for documentation */
1826    private boolean getEapAltSubjectMatch() {
1827        synchronized (mLock) {
1828            final String methodStr = "getEapAltSubjectMatch";
1829            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1830            try {
1831                MutableBoolean statusOk = new MutableBoolean(false);
1832                mISupplicantStaNetwork.getEapAltSubjectMatch((SupplicantStatus status,
1833                        String matchValue) -> {
1834                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1835                    if (statusOk.value) {
1836                        this.mEapAltSubjectMatch = matchValue;
1837                    } else {
1838                        logFailureStatus(status, methodStr);
1839                    }
1840                });
1841                return statusOk.value;
1842            } catch (RemoteException e) {
1843                handleRemoteException(e, methodStr);
1844                return false;
1845            }
1846        }
1847    }
1848    /** See ISupplicantStaNetwork.hal for documentation */
1849    private boolean getEapEngine() {
1850        synchronized (mLock) {
1851            final String methodStr = "getEapEngine";
1852            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1853            try {
1854                MutableBoolean statusOk = new MutableBoolean(false);
1855                mISupplicantStaNetwork.getEapEngine((SupplicantStatus status,
1856                        boolean enabledValue) -> {
1857                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1858                    if (statusOk.value) {
1859                        this.mEapEngine = enabledValue;
1860                    } else {
1861                        logFailureStatus(status, methodStr);
1862                    }
1863                });
1864                return statusOk.value;
1865            } catch (RemoteException e) {
1866                handleRemoteException(e, methodStr);
1867                return false;
1868            }
1869        }
1870    }
1871    /** See ISupplicantStaNetwork.hal for documentation */
1872    private boolean getEapEngineID() {
1873        synchronized (mLock) {
1874            final String methodStr = "getEapEngineID";
1875            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1876            try {
1877                MutableBoolean statusOk = new MutableBoolean(false);
1878                mISupplicantStaNetwork.getEapEngineID((SupplicantStatus status, String idValue) -> {
1879                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1880                    if (statusOk.value) {
1881                        this.mEapEngineID = idValue;
1882                    } else {
1883                        logFailureStatus(status, methodStr);
1884                    }
1885                });
1886                return statusOk.value;
1887            } catch (RemoteException e) {
1888                handleRemoteException(e, methodStr);
1889                return false;
1890            }
1891        }
1892    }
1893    /** See ISupplicantStaNetwork.hal for documentation */
1894    private boolean getEapDomainSuffixMatch() {
1895        synchronized (mLock) {
1896            final String methodStr = "getEapDomainSuffixMatch";
1897            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1898            try {
1899                MutableBoolean statusOk = new MutableBoolean(false);
1900                mISupplicantStaNetwork.getEapDomainSuffixMatch((SupplicantStatus status,
1901                        String matchValue) -> {
1902                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1903                    if (statusOk.value) {
1904                        this.mEapDomainSuffixMatch = matchValue;
1905                    } else {
1906                        logFailureStatus(status, methodStr);
1907                    }
1908                });
1909                return statusOk.value;
1910            } catch (RemoteException e) {
1911                handleRemoteException(e, methodStr);
1912                return false;
1913            }
1914        }
1915    }
1916    /** See ISupplicantStaNetwork.hal for documentation */
1917    private boolean getIdStr() {
1918        synchronized (mLock) {
1919            final String methodStr = "getIdStr";
1920            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1921            try {
1922                MutableBoolean statusOk = new MutableBoolean(false);
1923                mISupplicantStaNetwork.getIdStr((SupplicantStatus status, String idString) -> {
1924                    statusOk.value = status.code == SupplicantStatusCode.SUCCESS;
1925                    if (statusOk.value) {
1926                        this.mIdStr = idString;
1927                    } else {
1928                        logFailureStatus(status, methodStr);
1929                    }
1930                });
1931                return statusOk.value;
1932            } catch (RemoteException e) {
1933                handleRemoteException(e, methodStr);
1934                return false;
1935            }
1936        }
1937    }
1938    /** See ISupplicantStaNetwork.hal for documentation */
1939    private boolean enable(boolean noConnect) {
1940        synchronized (mLock) {
1941            final String methodStr = "enable";
1942            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1943            try {
1944                SupplicantStatus status =  mISupplicantStaNetwork.enable(noConnect);
1945                return checkStatusAndLogFailure(status, methodStr);
1946            } catch (RemoteException e) {
1947                handleRemoteException(e, methodStr);
1948                return false;
1949            }
1950        }
1951    }
1952    /** See ISupplicantStaNetwork.hal for documentation */
1953    private boolean disable() {
1954        synchronized (mLock) {
1955            final String methodStr = "disable";
1956            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1957            try {
1958                SupplicantStatus status =  mISupplicantStaNetwork.disable();
1959                return checkStatusAndLogFailure(status, methodStr);
1960            } catch (RemoteException e) {
1961                handleRemoteException(e, methodStr);
1962                return false;
1963            }
1964        }
1965    }
1966
1967    /**
1968     * Trigger a connection to this network.
1969     *
1970     * @return true if it succeeds, false otherwise.
1971     */
1972    public boolean select() {
1973        synchronized (mLock) {
1974            final String methodStr = "select";
1975            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
1976            try {
1977                SupplicantStatus status =  mISupplicantStaNetwork.select();
1978                return checkStatusAndLogFailure(status, methodStr);
1979            } catch (RemoteException e) {
1980                handleRemoteException(e, methodStr);
1981                return false;
1982            }
1983        }
1984    }
1985
1986    /**
1987     * Send GSM auth response.
1988     *
1989     * @param paramsStr Response params as a string.
1990     * @return true if succeeds, false otherwise.
1991     */
1992    public boolean sendNetworkEapSimGsmAuthResponse(String paramsStr) {
1993        Matcher match = GSM_AUTH_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
1994        ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params =
1995                new ArrayList<>();
1996        while (match.find()) {
1997            if (match.groupCount() != 2) {
1998                Log.e(TAG, "Malformed gsm auth response params: " + paramsStr);
1999                return false;
2000            }
2001            ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams param =
2002                    new ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams();
2003            byte[] kc = NativeUtil.hexStringToByteArray(match.group(1));
2004            if (kc == null || kc.length != param.kc.length) {
2005                Log.e(TAG, "Invalid kc value: " + match.group(1));
2006                return false;
2007            }
2008            byte[] sres = NativeUtil.hexStringToByteArray(match.group(2));
2009            if (sres == null || sres.length != param.sres.length) {
2010                Log.e(TAG, "Invalid sres value: " + match.group(2));
2011                return false;
2012            }
2013            System.arraycopy(kc, 0, param.kc, 0, param.kc.length);
2014            System.arraycopy(sres, 0, param.sres, 0, param.sres.length);
2015            params.add(param);
2016        }
2017        // The number of kc/sres pairs can either be 2 or 3 depending on the request.
2018        if (params.size() > 3 || params.size() < 2) {
2019            Log.e(TAG, "Malformed gsm auth response params: " + paramsStr);
2020            return false;
2021        }
2022        return sendNetworkEapSimGsmAuthResponse(params);
2023    }
2024
2025    /** See ISupplicantStaNetwork.hal for documentation */
2026    private boolean sendNetworkEapSimGsmAuthResponse(
2027            ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params) {
2028        synchronized (mLock) {
2029            final String methodStr = "sendNetworkEapSimGsmAuthResponse";
2030            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
2031            try {
2032                SupplicantStatus status =
2033                        mISupplicantStaNetwork.sendNetworkEapSimGsmAuthResponse(params);
2034                return checkStatusAndLogFailure(status, methodStr);
2035            } catch (RemoteException e) {
2036                handleRemoteException(e, methodStr);
2037                return false;
2038            }
2039        }
2040    }
2041    /** See ISupplicantStaNetwork.hal for documentation */
2042    public boolean sendNetworkEapSimGsmAuthFailure() {
2043        synchronized (mLock) {
2044            final String methodStr = "sendNetworkEapSimGsmAuthFailure";
2045            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
2046            try {
2047                SupplicantStatus status = mISupplicantStaNetwork.sendNetworkEapSimGsmAuthFailure();
2048                return checkStatusAndLogFailure(status, methodStr);
2049            } catch (RemoteException e) {
2050                handleRemoteException(e, methodStr);
2051                return false;
2052            }
2053        }
2054    }
2055    /**
2056     * Send UMTS auth response.
2057     *
2058     * @param paramsStr Response params as a string.
2059     * @return true if succeeds, false otherwise.
2060     */
2061    public boolean sendNetworkEapSimUmtsAuthResponse(String paramsStr) {
2062        Matcher match = UMTS_AUTH_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
2063        if (!match.find() || match.groupCount() != 3) {
2064            Log.e(TAG, "Malformed umts auth response params: " + paramsStr);
2065            return false;
2066        }
2067        ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params =
2068                new ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams();
2069        byte[] ik = NativeUtil.hexStringToByteArray(match.group(1));
2070        if (ik == null || ik.length != params.ik.length) {
2071            Log.e(TAG, "Invalid ik value: " + match.group(1));
2072            return false;
2073        }
2074        byte[] ck = NativeUtil.hexStringToByteArray(match.group(2));
2075        if (ck == null || ck.length != params.ck.length) {
2076            Log.e(TAG, "Invalid ck value: " + match.group(2));
2077            return false;
2078        }
2079        byte[] res = NativeUtil.hexStringToByteArray(match.group(3));
2080        if (res == null || res.length == 0) {
2081            Log.e(TAG, "Invalid res value: " + match.group(3));
2082            return false;
2083        }
2084        System.arraycopy(ik, 0, params.ik, 0, params.ik.length);
2085        System.arraycopy(ck, 0, params.ck, 0, params.ck.length);
2086        for (byte b : res) {
2087            params.res.add(b);
2088        }
2089        return sendNetworkEapSimUmtsAuthResponse(params);
2090    }
2091    /** See ISupplicantStaNetwork.hal for documentation */
2092    private boolean sendNetworkEapSimUmtsAuthResponse(
2093            ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params) {
2094        synchronized (mLock) {
2095            final String methodStr = "sendNetworkEapSimUmtsAuthResponse";
2096            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
2097            try {
2098                SupplicantStatus status =
2099                        mISupplicantStaNetwork.sendNetworkEapSimUmtsAuthResponse(params);
2100                return checkStatusAndLogFailure(status, methodStr);
2101            } catch (RemoteException e) {
2102                handleRemoteException(e, methodStr);
2103                return false;
2104            }
2105        }
2106    }
2107    /**
2108     * Send UMTS auts response.
2109     *
2110     * @param paramsStr Response params as a string.
2111     * @return true if succeeds, false otherwise.
2112     */
2113    public boolean sendNetworkEapSimUmtsAutsResponse(String paramsStr) {
2114        Matcher match = UMTS_AUTS_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
2115        if (!match.find() || match.groupCount() != 1) {
2116            Log.e(TAG, "Malformed umts auts response params: " + paramsStr);
2117            return false;
2118        }
2119        byte[] auts = NativeUtil.hexStringToByteArray(match.group(1));
2120        if (auts == null || auts.length != 14) {
2121            Log.e(TAG, "Invalid auts value: " + match.group(1));
2122            return false;
2123        }
2124        return sendNetworkEapSimUmtsAutsResponse(auts);
2125    }
2126    /** See ISupplicantStaNetwork.hal for documentation */
2127    private boolean sendNetworkEapSimUmtsAutsResponse(byte[/* 14 */] auts) {
2128        synchronized (mLock) {
2129            final String methodStr = "sendNetworkEapSimUmtsAutsResponse";
2130            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
2131            try {
2132                SupplicantStatus status =
2133                        mISupplicantStaNetwork.sendNetworkEapSimUmtsAutsResponse(auts);
2134                return checkStatusAndLogFailure(status, methodStr);
2135            } catch (RemoteException e) {
2136                handleRemoteException(e, methodStr);
2137                return false;
2138            }
2139        }
2140    }
2141    /** See ISupplicantStaNetwork.hal for documentation */
2142    public boolean sendNetworkEapSimUmtsAuthFailure() {
2143        synchronized (mLock) {
2144            final String methodStr = "sendNetworkEapSimUmtsAuthFailure";
2145            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
2146            try {
2147                SupplicantStatus status = mISupplicantStaNetwork.sendNetworkEapSimUmtsAuthFailure();
2148                return checkStatusAndLogFailure(status, methodStr);
2149            } catch (RemoteException e) {
2150                handleRemoteException(e, methodStr);
2151                return false;
2152            }
2153        }
2154    }
2155    /**
2156     * Send eap identity response.
2157     *
2158     * @param identityStr Identity as a string.
2159     * @return true if succeeds, false otherwise.
2160     */
2161    public boolean sendNetworkEapIdentityResponse(String identityStr) {
2162        ArrayList<Byte> identity = NativeUtil.stringToByteArrayList(identityStr);
2163        return sendNetworkEapIdentityResponse(identity);
2164    }
2165    /** See ISupplicantStaNetwork.hal for documentation */
2166    private boolean sendNetworkEapIdentityResponse(ArrayList<Byte> identity) {
2167        synchronized (mLock) {
2168            final String methodStr = "sendNetworkEapIdentityResponse";
2169            if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false;
2170            try {
2171                SupplicantStatus status =
2172                        mISupplicantStaNetwork.sendNetworkEapIdentityResponse(identity);
2173                return checkStatusAndLogFailure(status, methodStr);
2174            } catch (RemoteException e) {
2175                handleRemoteException(e, methodStr);
2176                return false;
2177            }
2178        }
2179    }
2180
2181    /**
2182     * Returns true if provided status code is SUCCESS, logs debug message and returns false
2183     * otherwise
2184     */
2185    private boolean checkStatusAndLogFailure(SupplicantStatus status, final String methodStr) {
2186        if (DBG) Log.i(TAG, methodStr);
2187        if (status.code != SupplicantStatusCode.SUCCESS) {
2188            Log.e(TAG, methodStr + " failed: "
2189                    + SupplicantStaIfaceHal.supplicantStatusCodeToString(status.code) + ", "
2190                    + status.debugMessage);
2191            return false;
2192        }
2193        return true;
2194    }
2195
2196    /**
2197     * Returns false if ISupplicantStaNetwork is null, and logs failure of methodStr
2198     */
2199    private boolean checkISupplicantStaNetworkAndLogFailure(final String methodStr) {
2200        if (mISupplicantStaNetwork == null) {
2201            Log.e(TAG, "Can't call " + methodStr + ", ISupplicantStaNetwork is null");
2202            return false;
2203        }
2204        return true;
2205    }
2206
2207    private void handleRemoteException(RemoteException e, String methodStr) {
2208        mISupplicantStaNetwork = null;
2209        Log.e(TAG, "ISupplicantStaNetwork." + methodStr + ":exception: " + e);
2210    }
2211
2212    private void logFailureStatus(SupplicantStatus status, String methodStr) {
2213        Log.e(TAG, methodStr + " failed: " + status.debugMessage);
2214    }
2215}
2216