AccessPoint.java revision b77d3d74752fca440349269ee661c02ee07af5db
1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settingslib.wifi;
18
19import android.annotation.IntDef;
20import android.annotation.Nullable;
21import android.app.AppGlobals;
22import android.content.Context;
23import android.content.pm.ApplicationInfo;
24import android.content.pm.IPackageManager;
25import android.content.pm.PackageManager;
26import android.net.ConnectivityManager;
27import android.net.NetworkCapabilities;
28import android.net.NetworkInfo;
29import android.net.NetworkInfo.DetailedState;
30import android.net.NetworkInfo.State;
31import android.net.NetworkKey;
32import android.net.NetworkScoreManager;
33import android.net.NetworkScorerAppData;
34import android.net.ScoredNetwork;
35import android.net.WifiKey;
36import android.net.wifi.IWifiManager;
37import android.net.wifi.ScanResult;
38import android.net.wifi.WifiConfiguration;
39import android.net.wifi.WifiConfiguration.KeyMgmt;
40import android.net.wifi.WifiInfo;
41import android.net.wifi.WifiManager;
42import android.net.wifi.WifiNetworkScoreCache;
43import android.net.wifi.hotspot2.PasspointConfiguration;
44import android.os.Bundle;
45import android.os.RemoteException;
46import android.os.ServiceManager;
47import android.os.SystemClock;
48import android.os.UserHandle;
49import android.support.annotation.NonNull;
50import android.text.Spannable;
51import android.text.SpannableString;
52import android.text.TextUtils;
53import android.text.style.TtsSpan;
54import android.util.Log;
55
56import com.android.internal.annotations.VisibleForTesting;
57import com.android.settingslib.R;
58
59import java.lang.annotation.Retention;
60import java.lang.annotation.RetentionPolicy;
61import java.util.ArrayList;
62import java.util.Iterator;
63import java.util.concurrent.ConcurrentHashMap;
64import java.util.concurrent.atomic.AtomicInteger;
65
66
67public class AccessPoint implements Comparable<AccessPoint> {
68    static final String TAG = "SettingsLib.AccessPoint";
69
70    /**
71     * Lower bound on the 2.4 GHz (802.11b/g/n) WLAN channels
72     */
73    public static final int LOWER_FREQ_24GHZ = 2400;
74
75    /**
76     * Upper bound on the 2.4 GHz (802.11b/g/n) WLAN channels
77     */
78    public static final int HIGHER_FREQ_24GHZ = 2500;
79
80    /**
81     * Lower bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
82     */
83    public static final int LOWER_FREQ_5GHZ = 4900;
84
85    /**
86     * Upper bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
87     */
88    public static final int HIGHER_FREQ_5GHZ = 5900;
89
90    @IntDef({Speed.NONE, Speed.SLOW, Speed.MODERATE, Speed.FAST, Speed.VERY_FAST})
91    @Retention(RetentionPolicy.SOURCE)
92    public @interface Speed {
93        /**
94         * Constant value representing an unlabeled / unscored network.
95         */
96        int NONE = 0;
97        /**
98         * Constant value representing a slow speed network connection.
99         */
100        int SLOW = 5;
101        /**
102         * Constant value representing a medium speed network connection.
103         */
104        int MODERATE = 10;
105        /**
106         * Constant value representing a fast speed network connection.
107         */
108        int FAST = 20;
109        /**
110         * Constant value representing a very fast speed network connection.
111         */
112        int VERY_FAST = 30;
113    }
114
115    /**
116     * Experimental: we should be able to show the user the list of BSSIDs and bands
117     *  for that SSID.
118     *  For now this data is used only with Verbose Logging so as to show the band and number
119     *  of BSSIDs on which that network is seen.
120     */
121    private final ConcurrentHashMap<String, ScanResult> mScanResultCache =
122            new ConcurrentHashMap<String, ScanResult>(32);
123    private static final long MAX_SCAN_RESULT_AGE_MS = 15000;
124
125    static final String KEY_NETWORKINFO = "key_networkinfo";
126    static final String KEY_WIFIINFO = "key_wifiinfo";
127    static final String KEY_SCANRESULT = "key_scanresult";
128    static final String KEY_SSID = "key_ssid";
129    static final String KEY_SECURITY = "key_security";
130    static final String KEY_SPEED = "key_speed";
131    static final String KEY_PSKTYPE = "key_psktype";
132    static final String KEY_SCANRESULTCACHE = "key_scanresultcache";
133    static final String KEY_CONFIG = "key_config";
134    static final String KEY_FQDN = "key_fqdn";
135    static final String KEY_PROVIDER_FRIENDLY_NAME = "key_provider_friendly_name";
136    static final AtomicInteger sLastId = new AtomicInteger(0);
137
138    /**
139     * These values are matched in string arrays -- changes must be kept in sync
140     */
141    public static final int SECURITY_NONE = 0;
142    public static final int SECURITY_WEP = 1;
143    public static final int SECURITY_PSK = 2;
144    public static final int SECURITY_EAP = 3;
145
146    private static final int PSK_UNKNOWN = 0;
147    private static final int PSK_WPA = 1;
148    private static final int PSK_WPA2 = 2;
149    private static final int PSK_WPA_WPA2 = 3;
150
151    /**
152     * The number of distinct wifi levels.
153     *
154     * <p>Must keep in sync with {@link R.array.wifi_signal} and {@link WifiManager#RSSI_LEVELS}.
155     */
156    public static final int SIGNAL_LEVELS = 5;
157
158    public static final int UNREACHABLE_RSSI = Integer.MIN_VALUE;
159
160    private final Context mContext;
161
162    private String ssid;
163    private String bssid;
164    private int security;
165    private int networkId = WifiConfiguration.INVALID_NETWORK_ID;
166
167    private int pskType = PSK_UNKNOWN;
168
169    private WifiConfiguration mConfig;
170
171    private int mRssi = UNREACHABLE_RSSI;
172    private long mSeen = 0;
173
174    private WifiInfo mInfo;
175    private NetworkInfo mNetworkInfo;
176    AccessPointListener mAccessPointListener;
177
178    private Object mTag;
179
180    private int mRankingScore = Integer.MIN_VALUE;
181    private int mSpeed = Speed.NONE;
182    private boolean mIsScoredNetworkMetered = false;
183
184    // used to co-relate internal vs returned accesspoint.
185    int mId;
186
187    /**
188     * Information associated with the {@link PasspointConfiguration}.  Only maintaining
189     * the relevant info to preserve spaces.
190     */
191    private String mFqdn;
192    private String mProviderFriendlyName;
193
194    public AccessPoint(Context context, Bundle savedState) {
195        mContext = context;
196        mConfig = savedState.getParcelable(KEY_CONFIG);
197        if (mConfig != null) {
198            loadConfig(mConfig);
199        }
200        if (savedState.containsKey(KEY_SSID)) {
201            ssid = savedState.getString(KEY_SSID);
202        }
203        if (savedState.containsKey(KEY_SECURITY)) {
204            security = savedState.getInt(KEY_SECURITY);
205        }
206        if (savedState.containsKey(KEY_SPEED)) {
207            mSpeed = savedState.getInt(KEY_SPEED);
208        }
209        if (savedState.containsKey(KEY_PSKTYPE)) {
210            pskType = savedState.getInt(KEY_PSKTYPE);
211        }
212        mInfo = savedState.getParcelable(KEY_WIFIINFO);
213        if (savedState.containsKey(KEY_NETWORKINFO)) {
214            mNetworkInfo = savedState.getParcelable(KEY_NETWORKINFO);
215        }
216        if (savedState.containsKey(KEY_SCANRESULTCACHE)) {
217            ArrayList<ScanResult> scanResultArrayList =
218                    savedState.getParcelableArrayList(KEY_SCANRESULTCACHE);
219            mScanResultCache.clear();
220            for (ScanResult result : scanResultArrayList) {
221                mScanResultCache.put(result.BSSID, result);
222            }
223        }
224        if (savedState.containsKey(KEY_FQDN)) {
225            mFqdn = savedState.getString(KEY_FQDN);
226        }
227        if (savedState.containsKey(KEY_PROVIDER_FRIENDLY_NAME)) {
228            mProviderFriendlyName = savedState.getString(KEY_PROVIDER_FRIENDLY_NAME);
229        }
230        update(mConfig, mInfo, mNetworkInfo);
231        updateRssi();
232        updateSeen();
233        mId = sLastId.incrementAndGet();
234    }
235
236    public AccessPoint(Context context, WifiConfiguration config) {
237        mContext = context;
238        loadConfig(config);
239        mId = sLastId.incrementAndGet();
240    }
241
242    /**
243     * Initialize an AccessPoint object for a {@link PasspointConfiguration}.  This is mainly
244     * used by "Saved Networks" page for managing the saved {@link PasspointConfiguration}.
245     */
246    public AccessPoint(Context context, PasspointConfiguration config) {
247        mContext = context;
248        mFqdn = config.getHomeSp().getFqdn();
249        mProviderFriendlyName = config.getHomeSp().getFriendlyName();
250        mId = sLastId.incrementAndGet();
251    }
252
253    AccessPoint(Context context, AccessPoint other) {
254        mContext = context;
255        copyFrom(other);
256    }
257
258    AccessPoint(Context context, ScanResult result) {
259        mContext = context;
260        initWithScanResult(result);
261        mId = sLastId.incrementAndGet();
262    }
263
264    /**
265     * Copy accesspoint information. NOTE: We do not copy tag information because that is never
266     * set on the internal copy.
267     * @param that
268     */
269    void copyFrom(AccessPoint that) {
270        that.evictOldScanResults();
271        this.ssid = that.ssid;
272        this.bssid = that.bssid;
273        this.security = that.security;
274        this.networkId = that.networkId;
275        this.pskType = that.pskType;
276        this.mConfig = that.mConfig; //TODO: Watch out, this object is mutated.
277        this.mRssi = that.mRssi;
278        this.mSeen = that.mSeen;
279        this.mInfo = that.mInfo;
280        this.mNetworkInfo = that.mNetworkInfo;
281        this.mScanResultCache.clear();
282        this.mScanResultCache.putAll(that.mScanResultCache);
283        this.mId = that.mId;
284        this.mSpeed = that.mSpeed;
285        this.mIsScoredNetworkMetered = that.mIsScoredNetworkMetered;
286        this.mRankingScore = that.mRankingScore;
287    }
288
289    /**
290    * Returns a negative integer, zero, or a positive integer if this AccessPoint is less than,
291    * equal to, or greater than the other AccessPoint.
292    *
293    * Sort order rules for AccessPoints:
294    *   1. Active before inactive
295    *   2. Reachable before unreachable
296    *   3. Saved before unsaved
297    *   4. (Internal only) Network ranking score
298    *   5. Stronger signal before weaker signal
299    *   6. SSID alphabetically
300    *
301    * Note that AccessPoints with a signal are usually also Reachable,
302    * and will thus appear before unreachable saved AccessPoints.
303    */
304    @Override
305    public int compareTo(@NonNull AccessPoint other) {
306        // Active one goes first.
307        if (isActive() && !other.isActive()) return -1;
308        if (!isActive() && other.isActive()) return 1;
309
310        // Reachable one goes before unreachable one.
311        if (isReachable() && !other.isReachable()) return -1;
312        if (!isReachable() && other.isReachable()) return 1;
313
314        // Configured (saved) one goes before unconfigured one.
315        if (isSaved() && !other.isSaved()) return -1;
316        if (!isSaved() && other.isSaved()) return 1;
317
318        // Higher scores go before lower scores
319        if (getRankingScore() != other.getRankingScore()) {
320            return (getRankingScore() > other.getRankingScore()) ? -1 : 1;
321        }
322
323        // Sort by signal strength, bucketed by level
324        int difference = WifiManager.calculateSignalLevel(other.mRssi, SIGNAL_LEVELS)
325                - WifiManager.calculateSignalLevel(mRssi, SIGNAL_LEVELS);
326        if (difference != 0) {
327            return difference;
328        }
329
330        // Sort by ssid.
331        difference = getSsidStr().compareToIgnoreCase(other.getSsidStr());
332        if (difference != 0) {
333            return difference;
334        }
335
336        // Do a case sensitive comparison to distinguish SSIDs that differ in case only
337        return getSsidStr().compareTo(other.getSsidStr());
338    }
339
340    @Override
341    public boolean equals(Object other) {
342        if (!(other instanceof AccessPoint)) return false;
343        return (this.compareTo((AccessPoint) other) == 0);
344    }
345
346    @Override
347    public int hashCode() {
348        int result = 0;
349        if (mInfo != null) result += 13 * mInfo.hashCode();
350        result += 19 * mRssi;
351        result += 23 * networkId;
352        result += 29 * ssid.hashCode();
353        return result;
354    }
355
356    @Override
357    public String toString() {
358        StringBuilder builder = new StringBuilder().append("AccessPoint(")
359                .append(ssid);
360        if (bssid != null) {
361            builder.append(":").append(bssid);
362        }
363        if (isSaved()) {
364            builder.append(',').append("saved");
365        }
366        if (isActive()) {
367            builder.append(',').append("active");
368        }
369        if (isEphemeral()) {
370            builder.append(',').append("ephemeral");
371        }
372        if (isConnectable()) {
373            builder.append(',').append("connectable");
374        }
375        if (security != SECURITY_NONE) {
376            builder.append(',').append(securityToString(security, pskType));
377        }
378        builder.append(",level=").append(getLevel());
379        if (mRankingScore != Integer.MIN_VALUE) {
380            builder.append(",rankingScore=").append(mRankingScore);
381        }
382        if (mSpeed != Speed.NONE) {
383            builder.append(",speed=").append(mSpeed);
384        }
385        builder.append(",metered=").append(isMetered());
386
387        return builder.append(')').toString();
388    }
389
390    /**
391     * Updates the AccessPoint rankingScore, metering, and speed, returning true if the data has
392     * changed.
393     *
394     * @param scoreCache The score cache to use to retrieve scores.
395     * @param scoringUiEnabled Whether to show scoring and badging UI.
396     */
397    boolean update(WifiNetworkScoreCache scoreCache, boolean scoringUiEnabled) {
398        boolean scoreChanged = false;
399        if (scoringUiEnabled) {
400            scoreChanged = updateScores(scoreCache);
401        }
402        return updateMetered(scoreCache) || scoreChanged;
403    }
404
405    /**
406     * Updates the AccessPoint rankingScore and speed, returning true if the data has changed.
407     *
408     * @param scoreCache The score cache to use to retrieve scores.
409     */
410    private boolean updateScores(WifiNetworkScoreCache scoreCache) {
411        int oldSpeed = mSpeed;
412        int oldRankingScore = mRankingScore;
413        mSpeed = Speed.NONE;
414        mRankingScore = Integer.MIN_VALUE;
415
416        if (isActive() && mInfo != null) {
417            NetworkKey key = new NetworkKey(new WifiKey(
418                    AccessPoint.convertToQuotedString(ssid), mInfo.getBSSID()));
419            ScoredNetwork score = scoreCache.getScoredNetwork(key);
420            if (score != null) {
421                mSpeed = score.calculateBadge(mInfo.getRssi());
422                if (score.hasRankingScore()) {
423                    mRankingScore = score.calculateRankingScore(mInfo.getRssi());
424                }
425            }
426        } else {
427            for (ScanResult result : mScanResultCache.values()) {
428                ScoredNetwork score = scoreCache.getScoredNetwork(result);
429                if (score == null) {
430                    continue;
431                }
432
433                if (score.hasRankingScore()) {
434                    mRankingScore =
435                            Math.max(mRankingScore, score.calculateRankingScore(result.level));
436                }
437                // TODO(sghuman): Rename calculateBadge API
438                mSpeed = Math.max(mSpeed, score.calculateBadge(result.level));
439            }
440        }
441
442        if(WifiTracker.sVerboseLogging) {
443            Log.i(TAG, String.format("%s: Set speed to %d", ssid, mSpeed));
444        }
445
446        return (oldSpeed != mSpeed || oldRankingScore != mRankingScore);
447    }
448
449    /**
450     * Updates the AccessPoint's metering based on {@link ScoredNetwork#meteredHint}, returning
451     * true if the metering changed.
452     */
453    private boolean updateMetered(WifiNetworkScoreCache scoreCache) {
454        boolean oldMetering = mIsScoredNetworkMetered;
455        mIsScoredNetworkMetered = false;
456
457        if (isActive() && mInfo != null) {
458            NetworkKey key = new NetworkKey(new WifiKey(
459                    AccessPoint.convertToQuotedString(ssid), mInfo.getBSSID()));
460            ScoredNetwork score = scoreCache.getScoredNetwork(key);
461            if (score != null) {
462                mIsScoredNetworkMetered |= score.meteredHint;
463            }
464        } else {
465            for (ScanResult result : mScanResultCache.values()) {
466                ScoredNetwork score = scoreCache.getScoredNetwork(result);
467                if (score == null) {
468                    continue;
469                }
470                mIsScoredNetworkMetered |= score.meteredHint;
471            }
472        }
473        return oldMetering == mIsScoredNetworkMetered;
474    }
475
476    private void evictOldScanResults() {
477        long nowMs = SystemClock.elapsedRealtime();
478        for (Iterator<ScanResult> iter = mScanResultCache.values().iterator(); iter.hasNext(); ) {
479            ScanResult result = iter.next();
480            // result timestamp is in microseconds
481            if (nowMs - result.timestamp / 1000 > MAX_SCAN_RESULT_AGE_MS) {
482                iter.remove();
483            }
484        }
485    }
486
487    public boolean matches(ScanResult result) {
488        return ssid.equals(result.SSID) && security == getSecurity(result);
489    }
490
491    public boolean matches(WifiConfiguration config) {
492        if (config.isPasspoint() && mConfig != null && mConfig.isPasspoint()) {
493            return ssid.equals(removeDoubleQuotes(config.SSID)) && config.FQDN.equals(mConfig.FQDN);
494        } else {
495            return ssid.equals(removeDoubleQuotes(config.SSID))
496                    && security == getSecurity(config)
497                    && (mConfig == null || mConfig.shared == config.shared);
498        }
499    }
500
501    public WifiConfiguration getConfig() {
502        return mConfig;
503    }
504
505    public String getPasspointFqdn() {
506        return mFqdn;
507    }
508
509    public void clearConfig() {
510        mConfig = null;
511        networkId = WifiConfiguration.INVALID_NETWORK_ID;
512    }
513
514    public WifiInfo getInfo() {
515        return mInfo;
516    }
517
518    /**
519     * Returns the number of levels to show for a Wifi icon, from 0 to {@link #SIGNAL_LEVELS}-1.
520     *
521     * <p>Use {@#isReachable()} to determine if an AccessPoint is in range, as this method will
522     * always return at least 0.
523     */
524    public int getLevel() {
525        return WifiManager.calculateSignalLevel(mRssi, SIGNAL_LEVELS);
526    }
527
528    public int getRssi() {
529        return mRssi;
530    }
531
532    /**
533     * Updates {@link #mRssi}.
534     *
535     * <p>If the given connection is active, the existing value of {@link #mRssi} will be returned.
536     * If the given AccessPoint is not active, a value will be calculated from previous scan
537     * results, returning the best RSSI for all matching AccessPoints averaged with the previous
538     * value. If the access point is not connected and there are no scan results, the rssi will be
539     * set to {@link #UNREACHABLE_RSSI}.
540     *
541     * <p>Old scan results will be evicted from the cache when this method is invoked.
542     */
543    private void updateRssi() {
544        evictOldScanResults();
545
546        if (this.isActive()) {
547            return;
548        }
549
550        int rssi = UNREACHABLE_RSSI;
551        for (ScanResult result : mScanResultCache.values()) {
552            if (result.level > rssi) {
553                rssi = result.level;
554            }
555        }
556
557        if (rssi != UNREACHABLE_RSSI && mRssi != UNREACHABLE_RSSI) {
558            mRssi = (mRssi + rssi) / 2; // half-life previous value
559        } else {
560            mRssi = rssi;
561        }
562    }
563
564    /**
565     * Updates {@link #mSeen} based on the scan result cache.
566     *
567     * <p>Old scan results will be evicted from the cache when this method is invoked.
568     */
569    private void updateSeen() {
570        evictOldScanResults();
571
572        // TODO(sghuman): Set to now if connected
573
574        long seen = 0;
575        for (ScanResult result : mScanResultCache.values()) {
576            if (result.timestamp > seen) {
577                seen = result.timestamp;
578            }
579        }
580
581        // Only replace the previous value if we have a recent scan result to use
582        if (seen != 0) {
583            mSeen = seen;
584        }
585    }
586
587    /**
588     * Returns if the network should be considered metered.
589     */
590    public boolean isMetered() {
591        return mIsScoredNetworkMetered
592                || WifiConfiguration.isMetered(mConfig, mInfo);
593    }
594
595    public NetworkInfo getNetworkInfo() {
596        return mNetworkInfo;
597    }
598
599    public int getSecurity() {
600        return security;
601    }
602
603    public String getSecurityString(boolean concise) {
604        Context context = mContext;
605        if (mConfig != null && mConfig.isPasspoint()) {
606            return concise ? context.getString(R.string.wifi_security_short_eap) :
607                context.getString(R.string.wifi_security_eap);
608        }
609        switch(security) {
610            case SECURITY_EAP:
611                return concise ? context.getString(R.string.wifi_security_short_eap) :
612                    context.getString(R.string.wifi_security_eap);
613            case SECURITY_PSK:
614                switch (pskType) {
615                    case PSK_WPA:
616                        return concise ? context.getString(R.string.wifi_security_short_wpa) :
617                            context.getString(R.string.wifi_security_wpa);
618                    case PSK_WPA2:
619                        return concise ? context.getString(R.string.wifi_security_short_wpa2) :
620                            context.getString(R.string.wifi_security_wpa2);
621                    case PSK_WPA_WPA2:
622                        return concise ? context.getString(R.string.wifi_security_short_wpa_wpa2) :
623                            context.getString(R.string.wifi_security_wpa_wpa2);
624                    case PSK_UNKNOWN:
625                    default:
626                        return concise ? context.getString(R.string.wifi_security_short_psk_generic)
627                                : context.getString(R.string.wifi_security_psk_generic);
628                }
629            case SECURITY_WEP:
630                return concise ? context.getString(R.string.wifi_security_short_wep) :
631                    context.getString(R.string.wifi_security_wep);
632            case SECURITY_NONE:
633            default:
634                return concise ? "" : context.getString(R.string.wifi_security_none);
635        }
636    }
637
638    public String getSsidStr() {
639        return ssid;
640    }
641
642    public String getBssid() {
643        return bssid;
644    }
645
646    public CharSequence getSsid() {
647        final SpannableString str = new SpannableString(ssid);
648        str.setSpan(new TtsSpan.TelephoneBuilder(ssid).build(), 0, ssid.length(),
649                Spannable.SPAN_INCLUSIVE_INCLUSIVE);
650        return str;
651    }
652
653    public String getConfigName() {
654        if (mConfig != null && mConfig.isPasspoint()) {
655            return mConfig.providerFriendlyName;
656        } else if (mFqdn != null) {
657            return mProviderFriendlyName;
658        } else {
659            return ssid;
660        }
661    }
662
663    public DetailedState getDetailedState() {
664        if (mNetworkInfo != null) {
665            return mNetworkInfo.getDetailedState();
666        }
667        Log.w(TAG, "NetworkInfo is null, cannot return detailed state");
668        return null;
669    }
670
671    public String getSavedNetworkSummary() {
672        WifiConfiguration config = mConfig;
673        if (config != null) {
674            PackageManager pm = mContext.getPackageManager();
675            String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
676            int userId = UserHandle.getUserId(config.creatorUid);
677            ApplicationInfo appInfo = null;
678            if (config.creatorName != null && config.creatorName.equals(systemName)) {
679                appInfo = mContext.getApplicationInfo();
680            } else {
681                try {
682                    IPackageManager ipm = AppGlobals.getPackageManager();
683                    appInfo = ipm.getApplicationInfo(config.creatorName, 0 /* flags */, userId);
684                } catch (RemoteException rex) {
685                }
686            }
687            if (appInfo != null &&
688                    !appInfo.packageName.equals(mContext.getString(R.string.settings_package)) &&
689                    !appInfo.packageName.equals(
690                    mContext.getString(R.string.certinstaller_package))) {
691                return mContext.getString(R.string.saved_network, appInfo.loadLabel(pm));
692            }
693        }
694        return "";
695    }
696
697    public String getSummary() {
698        return getSettingsSummary(mConfig);
699    }
700
701    public String getSettingsSummary() {
702        return getSettingsSummary(mConfig);
703    }
704
705    private String getSettingsSummary(WifiConfiguration config) {
706        // Update to new summary
707        StringBuilder summary = new StringBuilder();
708
709        if (isActive() && config != null && config.isPasspoint()) {
710            // This is the active connection on passpoint
711            summary.append(getSummary(mContext, getDetailedState(),
712                    false, config.providerFriendlyName));
713        } else if (isActive()) {
714            // This is the active connection on non-passpoint network
715            summary.append(getSummary(mContext, getDetailedState(),
716                    mInfo != null && mInfo.isEphemeral()));
717        } else if (config != null && config.isPasspoint()
718                && config.getNetworkSelectionStatus().isNetworkEnabled()) {
719            String format = mContext.getString(R.string.available_via_passpoint);
720            summary.append(String.format(format, config.providerFriendlyName));
721        } else if (config != null && config.hasNoInternetAccess()) {
722            int messageID = config.getNetworkSelectionStatus().isNetworkPermanentlyDisabled()
723                    ? R.string.wifi_no_internet_no_reconnect
724                    : R.string.wifi_no_internet;
725            summary.append(mContext.getString(messageID));
726        } else if (config != null && !config.getNetworkSelectionStatus().isNetworkEnabled()) {
727            WifiConfiguration.NetworkSelectionStatus networkStatus =
728                    config.getNetworkSelectionStatus();
729            switch (networkStatus.getNetworkSelectionDisableReason()) {
730                case WifiConfiguration.NetworkSelectionStatus.DISABLED_AUTHENTICATION_FAILURE:
731                    summary.append(mContext.getString(R.string.wifi_disabled_password_failure));
732                    break;
733                case WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD:
734                    summary.append(mContext.getString(R.string.wifi_check_password_try_again));
735                    break;
736                case WifiConfiguration.NetworkSelectionStatus.DISABLED_DHCP_FAILURE:
737                case WifiConfiguration.NetworkSelectionStatus.DISABLED_DNS_FAILURE:
738                    summary.append(mContext.getString(R.string.wifi_disabled_network_failure));
739                    break;
740                case WifiConfiguration.NetworkSelectionStatus.DISABLED_ASSOCIATION_REJECTION:
741                    summary.append(mContext.getString(R.string.wifi_disabled_generic));
742                    break;
743            }
744        } else if (config != null && config.getNetworkSelectionStatus().isNotRecommended()) {
745            summary.append(mContext.getString(R.string.wifi_disabled_by_recommendation_provider));
746        } else if (!isReachable()) { // Wifi out of range
747            summary.append(mContext.getString(R.string.wifi_not_in_range));
748        } else { // In range, not disabled.
749            if (config != null) { // Is saved network
750                // Last attempt to connect to this failed. Show reason why
751                switch (config.recentFailure.getAssociationStatus()) {
752                    case WifiConfiguration.RecentFailure.STATUS_AP_UNABLE_TO_HANDLE_NEW_STA:
753                        summary.append(mContext.getString(
754                                R.string.wifi_ap_unable_to_handle_new_sta));
755                        break;
756                    default:
757                        // "Saved"
758                        summary.append(mContext.getString(R.string.wifi_remembered));
759                        break;
760                }
761            }
762        }
763
764        if (WifiTracker.sVerboseLogging) {
765            // Add RSSI/band information for this config, what was seen up to 6 seconds ago
766            // verbose WiFi Logging is only turned on thru developers settings
767            if (isActive() && mInfo != null) {
768                summary.append(" f=" + Integer.toString(mInfo.getFrequency()));
769            }
770            summary.append(" " + getVisibilityStatus());
771            if (config != null && !config.getNetworkSelectionStatus().isNetworkEnabled()) {
772                summary.append(" (" + config.getNetworkSelectionStatus().getNetworkStatusString());
773                if (config.getNetworkSelectionStatus().getDisableTime() > 0) {
774                    long now = System.currentTimeMillis();
775                    long diff = (now - config.getNetworkSelectionStatus().getDisableTime()) / 1000;
776                    long sec = diff%60; //seconds
777                    long min = (diff/60)%60; //minutes
778                    long hour = (min/60)%60; //hours
779                    summary.append(", ");
780                    if (hour > 0) summary.append(Long.toString(hour) + "h ");
781                    summary.append( Long.toString(min) + "m ");
782                    summary.append( Long.toString(sec) + "s ");
783                }
784                summary.append(")");
785            }
786
787            if (config != null) {
788                WifiConfiguration.NetworkSelectionStatus networkStatus =
789                        config.getNetworkSelectionStatus();
790                for (int index = WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLE;
791                        index < WifiConfiguration.NetworkSelectionStatus
792                        .NETWORK_SELECTION_DISABLED_MAX; index++) {
793                    if (networkStatus.getDisableReasonCounter(index) != 0) {
794                        summary.append(" " + WifiConfiguration.NetworkSelectionStatus
795                                .getNetworkDisableReasonString(index) + "="
796                                + networkStatus.getDisableReasonCounter(index));
797                    }
798                }
799            }
800        }
801
802        // If Speed label is present, use the preference combination to prepend it to the summary.
803        if (mSpeed != Speed.NONE) {
804            return mContext.getResources().getString(
805                    R.string.preference_summary_default_combination,
806                    getSpeedLabel(),
807                    summary.toString());
808        } else {
809            return summary.toString();
810        }
811    }
812
813    /**
814     * Returns the visibility status of the WifiConfiguration.
815     *
816     * @return autojoin debugging information
817     * TODO: use a string formatter
818     * ["rssi 5Ghz", "num results on 5GHz" / "rssi 5Ghz", "num results on 5GHz"]
819     * For instance [-40,5/-30,2]
820     */
821    private String getVisibilityStatus() {
822        StringBuilder visibility = new StringBuilder();
823        StringBuilder scans24GHz = null;
824        StringBuilder scans5GHz = null;
825        String bssid = null;
826
827        long now = System.currentTimeMillis();
828
829        if (isActive() && mInfo != null) {
830            bssid = mInfo.getBSSID();
831            if (bssid != null) {
832                visibility.append(" ").append(bssid);
833            }
834            visibility.append(" rssi=").append(mInfo.getRssi());
835            visibility.append(" ");
836            visibility.append(" score=").append(mInfo.score);
837            if (mRankingScore != Integer.MIN_VALUE) {
838                visibility.append(" rankingScore=").append(getRankingScore());
839            }
840            if (mSpeed != Speed.NONE) {
841                visibility.append(" speed=").append(getSpeedLabel());
842            }
843            visibility.append(String.format(" tx=%.1f,", mInfo.txSuccessRate));
844            visibility.append(String.format("%.1f,", mInfo.txRetriesRate));
845            visibility.append(String.format("%.1f ", mInfo.txBadRate));
846            visibility.append(String.format("rx=%.1f", mInfo.rxSuccessRate));
847        }
848
849        int rssi5 = WifiConfiguration.INVALID_RSSI;
850        int rssi24 = WifiConfiguration.INVALID_RSSI;
851        int num5 = 0;
852        int num24 = 0;
853        int numBlackListed = 0;
854        int n24 = 0; // Number scan results we included in the string
855        int n5 = 0; // Number scan results we included in the string
856        evictOldScanResults();
857        // TODO: sort list by RSSI or age
858        for (ScanResult result : mScanResultCache.values()) {
859
860            if (result.frequency >= LOWER_FREQ_5GHZ
861                    && result.frequency <= HIGHER_FREQ_5GHZ) {
862                // Strictly speaking: [4915, 5825]
863                // number of known BSSID on 5GHz band
864                num5 = num5 + 1;
865            } else if (result.frequency >= LOWER_FREQ_24GHZ
866                    && result.frequency <= HIGHER_FREQ_24GHZ) {
867                // Strictly speaking: [2412, 2482]
868                // number of known BSSID on 2.4Ghz band
869                num24 = num24 + 1;
870            }
871
872
873            if (result.frequency >= LOWER_FREQ_5GHZ
874                    && result.frequency <= HIGHER_FREQ_5GHZ) {
875                if (result.level > rssi5) {
876                    rssi5 = result.level;
877                }
878                if (n5 < 4) {
879                    if (scans5GHz == null) scans5GHz = new StringBuilder();
880                    scans5GHz.append(" \n{").append(result.BSSID);
881                    if (bssid != null && result.BSSID.equals(bssid)) scans5GHz.append("*");
882                    scans5GHz.append("=").append(result.frequency);
883                    scans5GHz.append(",").append(result.level);
884                    scans5GHz.append("}");
885                    n5++;
886                }
887            } else if (result.frequency >= LOWER_FREQ_24GHZ
888                    && result.frequency <= HIGHER_FREQ_24GHZ) {
889                if (result.level > rssi24) {
890                    rssi24 = result.level;
891                }
892                if (n24 < 4) {
893                    if (scans24GHz == null) scans24GHz = new StringBuilder();
894                    scans24GHz.append(" \n{").append(result.BSSID);
895                    if (bssid != null && result.BSSID.equals(bssid)) scans24GHz.append("*");
896                    scans24GHz.append("=").append(result.frequency);
897                    scans24GHz.append(",").append(result.level);
898                    scans24GHz.append("}");
899                    n24++;
900                }
901            }
902        }
903        visibility.append(" [");
904        if (num24 > 0) {
905            visibility.append("(").append(num24).append(")");
906            if (n24 <= 4) {
907                if (scans24GHz != null) {
908                    visibility.append(scans24GHz.toString());
909                }
910            } else {
911                visibility.append("max=").append(rssi24);
912                if (scans24GHz != null) {
913                    visibility.append(",").append(scans24GHz.toString());
914                }
915            }
916        }
917        visibility.append(";");
918        if (num5 > 0) {
919            visibility.append("(").append(num5).append(")");
920            if (n5 <= 4) {
921                if (scans5GHz != null) {
922                    visibility.append(scans5GHz.toString());
923                }
924            } else {
925                visibility.append("max=").append(rssi5);
926                if (scans5GHz != null) {
927                    visibility.append(",").append(scans5GHz.toString());
928                }
929            }
930        }
931        if (numBlackListed > 0)
932            visibility.append("!").append(numBlackListed);
933        visibility.append("]");
934
935        return visibility.toString();
936    }
937
938    /**
939     * Return whether this is the active connection.
940     * For ephemeral connections (networkId is invalid), this returns false if the network is
941     * disconnected.
942     */
943    public boolean isActive() {
944        return mNetworkInfo != null &&
945                (networkId != WifiConfiguration.INVALID_NETWORK_ID ||
946                 mNetworkInfo.getState() != State.DISCONNECTED);
947    }
948
949    public boolean isConnectable() {
950        return getLevel() != -1 && getDetailedState() == null;
951    }
952
953    public boolean isEphemeral() {
954        return mInfo != null && mInfo.isEphemeral() &&
955                mNetworkInfo != null && mNetworkInfo.getState() != State.DISCONNECTED;
956    }
957
958    /**
959     * Return true if this AccessPoint represents a Passpoint AP.
960     */
961    public boolean isPasspoint() {
962        return mConfig != null && mConfig.isPasspoint();
963    }
964
965    /**
966     * Return true if this AccessPoint represents a Passpoint provider configuration.
967     */
968    public boolean isPasspointConfig() {
969        return mFqdn != null;
970    }
971
972    /**
973     * Return whether the given {@link WifiInfo} is for this access point.
974     * If the current AP does not have a network Id then the config is used to
975     * match based on SSID and security.
976     */
977    private boolean isInfoForThisAccessPoint(WifiConfiguration config, WifiInfo info) {
978        if (isPasspoint() == false && networkId != WifiConfiguration.INVALID_NETWORK_ID) {
979            return networkId == info.getNetworkId();
980        } else if (config != null) {
981            return matches(config);
982        }
983        else {
984            // Might be an ephemeral connection with no WifiConfiguration. Try matching on SSID.
985            // (Note that we only do this if the WifiConfiguration explicitly equals INVALID).
986            // TODO: Handle hex string SSIDs.
987            return ssid.equals(removeDoubleQuotes(info.getSSID()));
988        }
989    }
990
991    public boolean isSaved() {
992        return networkId != WifiConfiguration.INVALID_NETWORK_ID;
993    }
994
995    public Object getTag() {
996        return mTag;
997    }
998
999    public void setTag(Object tag) {
1000        mTag = tag;
1001    }
1002
1003    /**
1004     * Generate and save a default wifiConfiguration with common values.
1005     * Can only be called for unsecured networks.
1006     */
1007    public void generateOpenNetworkConfig() {
1008        if (security != SECURITY_NONE)
1009            throw new IllegalStateException();
1010        if (mConfig != null)
1011            return;
1012        mConfig = new WifiConfiguration();
1013        mConfig.SSID = AccessPoint.convertToQuotedString(ssid);
1014        mConfig.allowedKeyManagement.set(KeyMgmt.NONE);
1015    }
1016
1017    void loadConfig(WifiConfiguration config) {
1018        ssid = (config.SSID == null ? "" : removeDoubleQuotes(config.SSID));
1019        bssid = config.BSSID;
1020        security = getSecurity(config);
1021        networkId = config.networkId;
1022        mConfig = config;
1023    }
1024
1025    private void initWithScanResult(ScanResult result) {
1026        ssid = result.SSID;
1027        bssid = result.BSSID;
1028        security = getSecurity(result);
1029        if (security == SECURITY_PSK)
1030            pskType = getPskType(result);
1031
1032        mScanResultCache.put(result.BSSID, result);
1033        updateRssi();
1034        mSeen = result.timestamp; // even if the timestamp is old it is still valid
1035    }
1036
1037    public void saveWifiState(Bundle savedState) {
1038        if (ssid != null) savedState.putString(KEY_SSID, getSsidStr());
1039        savedState.putInt(KEY_SECURITY, security);
1040        savedState.putInt(KEY_SPEED, mSpeed);
1041        savedState.putInt(KEY_PSKTYPE, pskType);
1042        if (mConfig != null) savedState.putParcelable(KEY_CONFIG, mConfig);
1043        savedState.putParcelable(KEY_WIFIINFO, mInfo);
1044        evictOldScanResults();
1045        savedState.putParcelableArrayList(KEY_SCANRESULTCACHE,
1046                new ArrayList<ScanResult>(mScanResultCache.values()));
1047        if (mNetworkInfo != null) {
1048            savedState.putParcelable(KEY_NETWORKINFO, mNetworkInfo);
1049        }
1050        if (mFqdn != null) {
1051            savedState.putString(KEY_FQDN, mFqdn);
1052        }
1053        if (mProviderFriendlyName != null) {
1054            savedState.putString(KEY_PROVIDER_FRIENDLY_NAME, mProviderFriendlyName);
1055        }
1056    }
1057
1058    public void setListener(AccessPointListener listener) {
1059        mAccessPointListener = listener;
1060    }
1061
1062    boolean update(ScanResult result) {
1063        if (matches(result)) {
1064            int oldLevel = getLevel();
1065
1066            /* Add or update the scan result for the BSSID */
1067            mScanResultCache.put(result.BSSID, result);
1068            updateSeen();
1069            updateRssi();
1070            int newLevel = getLevel();
1071
1072            if (newLevel > 0 && newLevel != oldLevel && mAccessPointListener != null) {
1073                mAccessPointListener.onLevelChanged(this);
1074            }
1075            // This flag only comes from scans, is not easily saved in config
1076            if (security == SECURITY_PSK) {
1077                pskType = getPskType(result);
1078            }
1079
1080            if (mAccessPointListener != null) {
1081                mAccessPointListener.onAccessPointChanged(this);
1082            }
1083
1084            return true;
1085        }
1086        return false;
1087    }
1088
1089    /** Attempt to update the AccessPoint and return true if an update occurred. */
1090    public boolean update(
1091            @Nullable WifiConfiguration config, WifiInfo info, NetworkInfo networkInfo) {
1092        boolean updated = false;
1093        final int oldLevel = getLevel();
1094        if (info != null && isInfoForThisAccessPoint(config, info)) {
1095            updated = (mInfo == null);
1096            if (mConfig != config) {
1097                // We do not set updated = true as we do not want to increase the amount of sorting
1098                // and copying performed in WifiTracker at this time. If issues involving refresh
1099                // are still seen, we will investigate further.
1100                update(config); // Notifies the AccessPointListener of the change
1101            }
1102            if (mRssi != info.getRssi()) {
1103                mRssi = info.getRssi();
1104                updated = true;
1105            } else if (mNetworkInfo != null && networkInfo != null
1106                    && mNetworkInfo.getDetailedState() != networkInfo.getDetailedState()) {
1107                updated = true;
1108            }
1109            mInfo = info;
1110            mNetworkInfo = networkInfo;
1111        } else if (mInfo != null) {
1112            updated = true;
1113            mInfo = null;
1114            mNetworkInfo = null;
1115        }
1116        if (updated && mAccessPointListener != null) {
1117            mAccessPointListener.onAccessPointChanged(this);
1118
1119            if (oldLevel != getLevel() /* current level */) {
1120                mAccessPointListener.onLevelChanged(this);
1121            }
1122        }
1123        return updated;
1124    }
1125
1126    void update(@Nullable WifiConfiguration config) {
1127        mConfig = config;
1128        networkId = config != null ? config.networkId : WifiConfiguration.INVALID_NETWORK_ID;
1129        if (mAccessPointListener != null) {
1130            mAccessPointListener.onAccessPointChanged(this);
1131        }
1132    }
1133
1134    @VisibleForTesting
1135    void setRssi(int rssi) {
1136        mRssi = rssi;
1137    }
1138
1139    /** Sets the rssi to {@link #UNREACHABLE_RSSI}. */
1140    void setUnreachable() {
1141        setRssi(AccessPoint.UNREACHABLE_RSSI);
1142    }
1143
1144    int getRankingScore() {
1145        return mRankingScore;
1146    }
1147
1148    int getSpeed() { return mSpeed;}
1149
1150    @Nullable
1151    String getSpeedLabel() {
1152        switch (mSpeed) {
1153            case Speed.VERY_FAST:
1154                return mContext.getString(R.string.speed_label_very_fast);
1155            case Speed.FAST:
1156                return mContext.getString(R.string.speed_label_fast);
1157            case Speed.MODERATE:
1158                return mContext.getString(R.string.speed_label_okay);
1159            case Speed.SLOW:
1160                return mContext.getString(R.string.speed_label_slow);
1161            case Speed.NONE:
1162            default:
1163                return null;
1164        }
1165    }
1166
1167    /** Return true if the current RSSI is reachable, and false otherwise. */
1168    public boolean isReachable() {
1169        return mRssi != UNREACHABLE_RSSI;
1170    }
1171
1172    public static String getSummary(Context context, String ssid, DetailedState state,
1173            boolean isEphemeral, String passpointProvider) {
1174        if (state == DetailedState.CONNECTED && ssid == null) {
1175            if (TextUtils.isEmpty(passpointProvider) == false) {
1176                // Special case for connected + passpoint networks.
1177                String format = context.getString(R.string.connected_via_passpoint);
1178                return String.format(format, passpointProvider);
1179            } else if (isEphemeral) {
1180                // Special case for connected + ephemeral networks.
1181                final NetworkScoreManager networkScoreManager = context.getSystemService(
1182                        NetworkScoreManager.class);
1183                NetworkScorerAppData scorer = networkScoreManager.getActiveScorer();
1184                if (scorer != null && scorer.getRecommendationServiceLabel() != null) {
1185                    String format = context.getString(R.string.connected_via_network_scorer);
1186                    return String.format(format, scorer.getRecommendationServiceLabel());
1187                } else {
1188                    return context.getString(R.string.connected_via_network_scorer_default);
1189                }
1190            }
1191        }
1192
1193        // Case when there is wifi connected without internet connectivity.
1194        final ConnectivityManager cm = (ConnectivityManager)
1195                context.getSystemService(Context.CONNECTIVITY_SERVICE);
1196        if (state == DetailedState.CONNECTED) {
1197            IWifiManager wifiManager = IWifiManager.Stub.asInterface(
1198                    ServiceManager.getService(Context.WIFI_SERVICE));
1199            NetworkCapabilities nc = null;
1200
1201            try {
1202                nc = cm.getNetworkCapabilities(wifiManager.getCurrentNetwork());
1203            } catch (RemoteException e) {}
1204
1205            if (nc != null) {
1206                if (nc.hasCapability(nc.NET_CAPABILITY_CAPTIVE_PORTAL)) {
1207                    int id = context.getResources()
1208                            .getIdentifier("network_available_sign_in", "string", "android");
1209                    return context.getString(id);
1210                } else if (!nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
1211                    return context.getString(R.string.wifi_connected_no_internet);
1212                }
1213            }
1214        }
1215        if (state == null) {
1216            Log.w(TAG, "state is null, returning empty summary");
1217            return "";
1218        }
1219        String[] formats = context.getResources().getStringArray((ssid == null)
1220                ? R.array.wifi_status : R.array.wifi_status_with_ssid);
1221        int index = state.ordinal();
1222
1223        if (index >= formats.length || formats[index].length() == 0) {
1224            return "";
1225        }
1226        return String.format(formats[index], ssid);
1227    }
1228
1229    public static String getSummary(Context context, DetailedState state, boolean isEphemeral) {
1230        return getSummary(context, null, state, isEphemeral, null);
1231    }
1232
1233    public static String getSummary(Context context, DetailedState state, boolean isEphemeral,
1234            String passpointProvider) {
1235        return getSummary(context, null, state, isEphemeral, passpointProvider);
1236    }
1237
1238    public static String convertToQuotedString(String string) {
1239        return "\"" + string + "\"";
1240    }
1241
1242    private static int getPskType(ScanResult result) {
1243        boolean wpa = result.capabilities.contains("WPA-PSK");
1244        boolean wpa2 = result.capabilities.contains("WPA2-PSK");
1245        if (wpa2 && wpa) {
1246            return PSK_WPA_WPA2;
1247        } else if (wpa2) {
1248            return PSK_WPA2;
1249        } else if (wpa) {
1250            return PSK_WPA;
1251        } else {
1252            Log.w(TAG, "Received abnormal flag string: " + result.capabilities);
1253            return PSK_UNKNOWN;
1254        }
1255    }
1256
1257    private static int getSecurity(ScanResult result) {
1258        if (result.capabilities.contains("WEP")) {
1259            return SECURITY_WEP;
1260        } else if (result.capabilities.contains("PSK")) {
1261            return SECURITY_PSK;
1262        } else if (result.capabilities.contains("EAP")) {
1263            return SECURITY_EAP;
1264        }
1265        return SECURITY_NONE;
1266    }
1267
1268    static int getSecurity(WifiConfiguration config) {
1269        if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
1270            return SECURITY_PSK;
1271        }
1272        if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) ||
1273                config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) {
1274            return SECURITY_EAP;
1275        }
1276        return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE;
1277    }
1278
1279    public static String securityToString(int security, int pskType) {
1280        if (security == SECURITY_WEP) {
1281            return "WEP";
1282        } else if (security == SECURITY_PSK) {
1283            if (pskType == PSK_WPA) {
1284                return "WPA";
1285            } else if (pskType == PSK_WPA2) {
1286                return "WPA2";
1287            } else if (pskType == PSK_WPA_WPA2) {
1288                return "WPA_WPA2";
1289            }
1290            return "PSK";
1291        } else if (security == SECURITY_EAP) {
1292            return "EAP";
1293        }
1294        return "NONE";
1295    }
1296
1297    static String removeDoubleQuotes(String string) {
1298        if (TextUtils.isEmpty(string)) {
1299            return "";
1300        }
1301        int length = string.length();
1302        if ((length > 1) && (string.charAt(0) == '"')
1303                && (string.charAt(length - 1) == '"')) {
1304            return string.substring(1, length - 1);
1305        }
1306        return string;
1307    }
1308
1309    public interface AccessPointListener {
1310        void onAccessPointChanged(AccessPoint accessPoint);
1311        void onLevelChanged(AccessPoint accessPoint);
1312    }
1313}
1314