Java 类android.net.wifi.ScanResult 实例源码

项目:WifiUtils    文件:ConfigSecurities.java   
@Nullable
static WifiConfiguration getWifiConfiguration(@NonNull final WifiManager wifiMgr, @NonNull final ScanResult scanResult) {
    if (scanResult.BSSID == null || scanResult.SSID == null || scanResult.SSID.isEmpty() || scanResult.BSSID.isEmpty())
        return null;
    final String ssid = convertToQuotedString(scanResult.SSID);
    final String bssid = scanResult.BSSID;
    final String security = getSecurity(scanResult);

    final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
    if (configurations == null)
        return null;

    for (final WifiConfiguration config : configurations) {
        if (bssid.equals(config.BSSID) || ssid.equals(config.SSID)) {
            final String configSecurity = getSecurity(config);
            if (Objects.equals(security, configSecurity))
                return config;
        }
    }
    return null;
}
项目:PrivacyStreams    文件:WifiApListProvider.java   
@Override
public void onReceive(Context context, Intent intent)
{
    WifiManager wifiMgr = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
    String name = wifiInfo.getSSID();
    for(ScanResult result: wifiMgr.getScanResults()){
        WifiApListProvider.this.output(new WifiAp(result, name.equals(result.SSID)));
    }
    WifiApListProvider.this.finish();
}
项目:YiZhi    文件:WifiAutoConnectManager.java   
public static WifiCipherType getCipherType(Context context, String ssid) {
    WifiManager wifiManager = (WifiManager) context
            .getSystemService(Context.WIFI_SERVICE);

    List<ScanResult> list = wifiManager.getScanResults();

    for (ScanResult scResult : list) {

        if (!StringUtils.isEmpty(scResult.SSID) && scResult.SSID.equals(ssid)) {
            String capabilities = scResult.capabilities;

            if (!StringUtils.isEmpty(capabilities)) {

                if (capabilities.contains("WPA")
                        || capabilities.contains("wpa")) {
                    LogUtils.i("wpa");
                    return WifiCipherType.WIFICIPHER_WPA;
                } else if (capabilities.contains("WEP")
                        || capabilities.contains("wep")) {
                    LogUtils.i("wep");
                    return WifiCipherType.WIFICIPHER_WEP;
                } else {
                    LogUtils.i("no");
                    return WifiCipherType.WIFICIPHER_NOPASS;
                }
            }
        }
    }
    return WifiCipherType.WIFICIPHER_INVALID;
}
项目:DejaVu    文件:BackendService.java   
/**
 * Call back method entered when Android has completed a scan for WiFi emitters in
 * the area.
 */
private void onWiFisChanged() {
    if ((wm != null) && (emitterCache != null)) {
        List<ScanResult> scanResults = wm.getScanResults();
        Set<Observation> observations = new HashSet<Observation>();
        for (ScanResult sr : scanResults) {
            String bssid = sr.BSSID.toLowerCase(Locale.US).replace(".", ":");
            if (bssid != null) {
                Observation o = new Observation(bssid, RfEmitter.EmitterType.WLAN);

                o.setAsu(WifiManager.calculateSignalLevel(sr.level, MAXIMUM_ASU));
                o.setNote(sr.SSID);
                observations.add(o);
            }
        }
        if (!observations.isEmpty()) {
            // Log.d(TAG, "onWiFisChanged(): Observations: " + observations.toString());
            queueForProcessing(observations, RfEmitter.EmitterType.WLAN, System.currentTimeMillis());
        }
    }
}
项目:AndroidBasicLibs    文件:NetUtils.java   
public static ScanResult getScanResultsByBSSID(Context context, String bssid) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    ScanResult scanResult = null;
    boolean f = wifiManager.startScan();
    if (!f) {
        getScanResultsByBSSID(context, bssid);
    }
    List<ScanResult> list = wifiManager.getScanResults();
    if (list != null) {
        for (int i = 0; i < list.size(); i++) {
            scanResult = list.get(i);
            if (scanResult.BSSID.equals(bssid)) {
                break;
            }
        }
    }
    return scanResult;
}
项目:letv    文件:c.java   
public final void a(int i, int i2, int i3, int i4, List<ScanResult> list) {
    this.b = System.currentTimeMillis();
    this.e = null;
    this.c.clear();
    a aVar = new a();
    aVar.a = i;
    aVar.b = i2;
    aVar.c = i3;
    aVar.d = i4;
    this.c.add(aVar);
    if (list != null) {
        this.d.clear();
        for (int i5 = 0; i5 < list.size(); i5++) {
            b bVar = new b();
            bVar.a = ((ScanResult) list.get(i5)).BSSID;
            int i6 = ((ScanResult) list.get(i5)).level;
            this.d.add(bVar);
        }
    }
}
项目:letv    文件:NetworkHelper.java   
public static boolean wifiConnection(Context context, String wifiSSID, String password) {
    WifiManager wifi = (WifiManager) context.getSystemService("wifi");
    String strQuotationSSID = "\"" + wifiSSID + "\"";
    WifiInfo wifiInfo = wifi.getConnectionInfo();
    if (wifiInfo != null && (wifiSSID.equals(wifiInfo.getSSID()) || strQuotationSSID.equals(wifiInfo.getSSID()))) {
        return true;
    }
    List<ScanResult> scanResults = wifi.getScanResults();
    if (scanResults == null || scanResults.size() == 0) {
        return false;
    }
    for (int nAllIndex = scanResults.size() - 1; nAllIndex >= 0; nAllIndex--) {
        String strScanSSID = ((ScanResult) scanResults.get(nAllIndex)).SSID;
        if (wifiSSID.equals(strScanSSID) || strQuotationSSID.equals(strScanSSID)) {
            WifiConfiguration config = new WifiConfiguration();
            config.SSID = strQuotationSSID;
            config.preSharedKey = "\"" + password + "\"";
            config.status = 2;
            return wifi.enableNetwork(wifi.addNetwork(config), false);
        }
    }
    return false;
}
项目:xlight_android_native    文件:BindDeviceSearchActivity.java   
/**
 * wifi列表
 */
private void getWifiList() {
    if (isWifiContect() && !stopScanWifi) {
        if (mWifiManager.getConnectionInfo().getSSID().contains("Photon-") && mWifiManager.getConnectionInfo().getSSID().length() == 11) {
            connectWifi(mWifiManager.getConnectionInfo().getSSID());
            return;
        }
        Log.d("XLight", "get scan wifi result");
        //获取结果
        List<ScanResult> wifiScanList = mWifiManager.getScanResults();
        //查看是否存在Photon-xxxx
        for (ScanResult sr : wifiScanList) {
            if (sr.SSID.contains("Photon-") && sr.SSID.length() == 11) {
                connectWifi(sr.SSID);
            }
        }
    }
}
项目:xlight_android_native    文件:WifiListAdapter.java   
@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (null == convertView) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.layout_wifi_list_item, null);

            holder.ssid = (TextView) convertView.findViewById(R.id.ssid);
            holder.lockIcon = (ImageView) convertView.findViewById(R.id.lockIcon);

            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        ScanResult wifiInfo = mScanResultList.get(position);
        holder.ssid.setText(wifiInfo.SSID);
//        holder.lockIcon.setVisibility(0 == deviceInfo.maindevice ? View.GONE : View.VISIBLE);

        return convertView;
    }
项目:xlight_android_native    文件:WifiScanResultLoader.java   
@Override
public Set<ScanResultNetwork> loadInBackground() {
    List<ScanResult> scanResults = wifiFacade.getScanResults();
    log.d("Latest (unfiltered) scan results: " + scanResults);

    if (loadCount % 3 == 0) {
        wifiFacade.startScan();
    }

    loadCount++;
    // filter the list, transform the matched results, then wrap those in a Set
    mostRecentResult = set(Funcy.transformList(
            scanResults, ssidStartsWithProductName, ScanResultNetwork::new));

    if (mostRecentResult.isEmpty()) {
        log.i("No SSID scan results returned after filtering by product name.  " +
                "Do you need to change the 'network_name_prefix' resource?");
    }

    return mostRecentResult;
}
项目:featurea    文件:WifiUtil.java   
public int connectToAP(Context context, String networkSSID, String networkPasskey) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    for (ScanResult result : wifiManager.getScanResults()) {
        if (result.SSID.equals(networkSSID)) {
            String securityMode = getScanResultSecurity(result);
            WifiConfiguration wifiConfiguration = createAPConfiguration(networkSSID, networkPasskey, securityMode);
            int res = wifiManager.addNetwork(wifiConfiguration);
            Log.d(TAG, "# addNetwork returned " + res);
            boolean b = wifiManager.enableNetwork(res, true);
            Log.d(TAG, "# enableNetwork returned " + b);
            wifiManager.setWifiEnabled(true);
            boolean changeHappen = wifiManager.saveConfiguration();
            if (res != -1 && changeHappen) {
                Log.d(TAG, "# Change happen: " + networkSSID);
            } else {
                Log.d(TAG, "# Change NOT happen");
            }
            return res;
        }
    }
    return -1;
}
项目:boohee_v5.6    文件:LocationInfo.java   
public List<Map<String, String>> getWifiListNearby() {
    List<Map<String, String>> arrayList = new ArrayList();
    if (this.a == null) {
        return arrayList;
    }
    WifiManager wifiManager = (WifiManager) this.a.getSystemService("wifi");
    if (wifiManager == null) {
        return arrayList;
    }
    List<ScanResult> scanResults = wifiManager.getScanResults();
    if (scanResults == null) {
        return arrayList;
    }
    for (ScanResult scanResult : scanResults) {
        Map hashMap = new HashMap();
        hashMap.put("wifiMac", scanResult.BSSID == null ? "" : scanResult.BSSID);
        hashMap.put("ssid", scanResult.SSID);
        hashMap.put("rssi", scanResult.level);
        arrayList.add(hashMap);
    }
    return arrayList;
}
项目:Lamp    文件:WifiConnectActivity.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;

    if (convertView == null) {
        holder = new ViewHolder();
        convertView = inflater.inflate(R.layout.wifi_list, null);
        holder.wifiName = (TextView) convertView.findViewById(R.id.wifi_name);
        convertView.setTag(holder);

    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    ScanResult scanResult = list.get(position);
    holder.wifiName.setText(scanResult.SSID);
    return convertView;
}
项目:TaipeiTechRefined    文件:WifiUtility.java   
public static ArrayList<String> getAvailableAPList(Context context) {
    ArrayList<String> apList = new ArrayList<String>();
    try {
        isNtutccAround = false;
        WifiManager wifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        List<ScanResult> scanResults = wifiManager.getScanResults();
        for (ScanResult result : scanResults) {
            apList.add(result.SSID + ":" + result.level + "dBm");
            if (result.SSID.equals("ntutcc")) {
                isNtutccAround = true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return apList;
}
项目:android-wificonnect    文件:WifiConnectionManager.java   
@Override
public void onScanResultsAvailable(List<ScanResult> scanResults) {
    onConnectionStateChanged(AdvancedConnectionState.SCAN_RESULTS_AVAILABLE);

    availableSSID = wifiHelper.findAvailableSSID(SSIDs, scanResults);
    if (reentrantLock.tryLock()) {
        wifiUtil.removeWifiScanResultsListener(this);

        if (availableSSID != null) {
            onSSIDAvailable(availableSSID);
        } else {
            String reason = "Couldn't find SSID in which we are interested";
            connectionStateListener.onConnectionError(reason);
            LOGGER.i(reason);
        }
    }
}
项目:upcKeygen    文件:WiFiNetwork.java   
private WiFiNetwork(Parcel in) {
    ssidName = in.readString();
    if (in.readInt() == 1)
        macAddress = in.readString();
    else
        macAddress = "";
    if (in.readInt() == 1)
        encryption = in.readString();
    else
        encryption = OPEN;
    level = in.readInt();
    mode = in.readInt();
    keygens = new ArrayList<>();
    in.readList(keygens, Keygen.class.getClassLoader());
    if (in.readInt() == 1)
        scanResult = in.readParcelable(ScanResult.class.getClassLoader());
    else
        scanResult = null;
}
项目:murmur    文件:HotspotPeerNetwork.java   
/**
 * Return true if the ScanResults are the same (all fields equal),
 * false otherwise.
 *
 * @param a A scan result to compare.
 * @param b Another scan result to compare.
 * @return Whether the given scan results seem to point to the same
 * network.
 */
private boolean scanResultsEqual(ScanResult a, ScanResult b) {
  if (a == null || b == null) {
    return a == b;
  } else {
    boolean sameBSSID = (a.BSSID == null ? 
                         b.BSSID == null : 
                         a.BSSID.equals(b.BSSID));
    boolean sameSSID = (a.SSID == null ? 
                        b.SSID == null : 
                        a.SSID.equals(b.SSID));
    boolean sameCapabilities = (a.capabilities == null ? 
                                b.capabilities == null : 
                                a.capabilities.equals(b.capabilities));
    boolean sameFrequency = (a.frequency == b.frequency);
    boolean sameTimestamp = (a.timestamp == b.timestamp);
    boolean sameLevel = (a.level == b.level);

    return sameBSSID && sameSSID && sameCapabilities &&
           sameFrequency && sameLevel && sameTimestamp;
  }
}
项目:murmur    文件:HotspotPeerNetwork.java   
/**
 * Return true if the ScanResults are the same (all fields equal),
 * false otherwise.
 *
 * @param a A scan result to compare.
 * @param b Another scan result to compare.
 * @return Whether the given scan results seem to point to the same
 * network.
 */
private boolean scanResultsEqual(ScanResult a, ScanResult b) {
  if (a == null || b == null) {
    return a == b;
  } else {
    boolean sameBSSID = (a.BSSID == null ? 
                         b.BSSID == null : 
                         a.BSSID.equals(b.BSSID));
    boolean sameSSID = (a.SSID == null ? 
                        b.SSID == null : 
                        a.SSID.equals(b.SSID));
    boolean sameCapabilities = (a.capabilities == null ? 
                                b.capabilities == null : 
                                a.capabilities.equals(b.capabilities));
    boolean sameFrequency = (a.frequency == b.frequency);
    boolean sameTimestamp = (a.timestamp == b.timestamp);
    boolean sameLevel = (a.level == b.level);

    return sameBSSID && sameSSID && sameCapabilities &&
           sameFrequency && sameLevel && sameTimestamp;
  }
}
项目:WifiTracker    文件:TrackManager.java   
public TrackRecord startRecord() throws AlreadyTrackingException {
    if (recording){
        throw new AlreadyTrackingException();
    }
    final TrackRecord tr = new TrackRecord();

    receiver = ScanReceiver.register(activity, new Consumer<List<ScanResult>>() {
        @Override
        public void accept(List<ScanResult> a) {
            tr.update(a);
        }
    });

    recording = true;

    return tr;

}
项目:Lokalisierung-mit-Wearables    文件:LocalizationClass.java   
@Override
public void onReceive(Context context, Intent intent) {
    List<ScanResult> currentResults = wifiManager.getScanResults();

    int measurementCount = currentResults.size();
    if (measurementCount > 0) {
        for (ScanResult result : currentResults) {
            wlanMeasure.add(new WiFiMeasurement(result.BSSID, result.level, result.SSID));
        }
        /* Call localization algorithm */
        findClosestPlaceIdWithScanResults();

        /* And start again: Continous scan */
        wifiManager.startScan();

    } else {
        stopLocalization();

        Toast.makeText(context, "Keine APs in der Umgebung gefunden", Toast.LENGTH_SHORT).show();
    }
}
项目:react-native-wifi-manager    文件:WifiManagerModule.java   
@ReactMethod
public void list(Callback successCallback, Callback errorCallback) {
  try {
    WifiManager mWifiManager = (WifiManager) getReactApplicationContext().getSystemService(Context.WIFI_SERVICE);
    List < ScanResult > results = mWifiManager.getScanResults();
    WritableArray wifiArray =  Arguments.createArray();
    for (ScanResult result: results) {
      if(!result.SSID.equals("")){
        wifiArray.pushString(result.SSID);
      }
    }
    successCallback.invoke(wifiArray);
  } catch (IllegalViewOperationException e) {
    errorCallback.invoke(e.getMessage());
  }
}
项目:WiFiPasswordSearcher    文件:WifiDetails.java   
private void ScanWorker() // THREADED!
{
    while(ScanThreadActive)
    {
        List<ScanResult> results;

        Boolean Founded = false;
        WifiMgr.startScan();
        results = WifiMgr.getScanResults();

        for (ScanResult result : results) {
            if (result.BSSID.equals(NetworkBSSID)) {
                WiFiInfo = result;
                Update();
                Founded = true;
                break;
            }
        }
        if(!Founded) setSignal("0");
        try {
            Thread.sleep((long)1000, 0);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
项目:WiFi-Buddy    文件:WifiDirectHandler.java   
private void handleScanResultsAvailable(Intent intent) {
    Log.i(TAG, "Wi-Fi scan results available");
    wifiScanResults = wifiManager.getScanResults();
    Log.i(TAG, "There are " + (wifiScanResults.size() - 1) + " available networks");
    for (ScanResult wifiScanResult : wifiScanResults) {
        Log.i(TAG, wifiScanResult.SSID);
    }

    // Unregister the Wi-Fi receiver and register it again without the SCAN_RESULTS action
    unregisterWifiReceiver();
    wifiBroadcastReceiver = new WifiBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter();

    // Indicates that Wi-Fi has been enabled, disabled, enabling, disabling, or unknown
    intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    registerReceiver(wifiBroadcastReceiver, intentFilter);
    Log.i(TAG, "Wi-Fi BroadcastReceiver registered");
}
项目:GOpenSource_AppKit_Android_AS    文件:GosChooseDeviceActivity.java   
private void initData() {
    list = new ArrayList<ScanResult>();
    list = (ArrayList<ScanResult>) GosConstant.ssidList;
    //list = (ArrayList<ScanResult>) NetUtils.getCurrentWifiScanResult(GosChooseDeviceActivity.this);
    softList = new ArrayList<ScanResult>();
    ScanResult scanResult;
    for (int i = 0; i < list.size(); i++) {
        scanResult = list.get(i);
        if (scanResult.SSID.length() > SoftAP_Start.length()) {
            if (scanResult.SSID.contains(SoftAP_Start)) {
                softList.add(scanResult);
            }
        }
    }
    myadapter = new Myadapter(softList);
    listView.setAdapter(myadapter);

}
项目:WiFiEye    文件:AvailableNetworksAdapter.java   
public void synchronizeData(List<ScanResult>availableNetworkList){
    Realm realm = Realm.getDefaultInstance();

    for (android.net.wifi.ScanResult network : availableNetworkList) {
        if (network.level < NetworkItem.MIN_SIGNAL_LEVEL)
            continue;
        final NetworkItem savedNetwork = realm.where(NetworkItem.class).equalTo(NetworkItem.FIELDNAME_SSID, network.SSID).findFirst();
        if (savedNetwork == null) {
            createNetworkItemFromBroadcast(realm, network);

        } else {
            //update level
            realm.beginTransaction();
            savedNetwork.setLevel(network.level);
            realm.commitTransaction();
        }

    }
    updateData(realm.where(NetworkItem.class).findAll().sort(NetworkItem.FIELDNAME_LEVEL, Sort.DESCENDING));
    notifyDataSetChanged();

}
项目:GizOpenSource_AppKit_Android    文件:GosChooseDeviceActivity.java   
private void initData() {
    list = new ArrayList<ScanResult>();
    list = (ArrayList<ScanResult>) GosConstant.ssidList;
    //list = (ArrayList<ScanResult>) NetUtils.getCurrentWifiScanResult(GosChooseDeviceActivity.this);
    softList = new ArrayList<ScanResult>();
    ScanResult scanResult;
    for (int i = 0; i < list.size(); i++) {
        scanResult = list.get(i);
        if (scanResult.SSID.length() > SoftAP_Start.length()) {
            if (scanResult.SSID.contains(SoftAP_Start)) {
                softList.add(scanResult);
            }
        }
    }
    myadapter = new Myadapter(softList);
    listView.setAdapter(myadapter);

}
项目:wifi_investigation_client    文件:MainActivity.java   
String createCSVFromScanResults(List<ScanResult> scanResults) {
    String csv = "";
    String sep = " ";
    for (ScanResult scan : scanResults) {
            /*
            JSONObject jsonScan = new JSONObject();
            jsonScan.put("ssid", scan.SSID);
            jsonScan.put("bssid", scan.BSSID);
            jsonScan.put("freq", scan.frequency);
            jsonScan.put("level", scan.level);
            jsonResults.put(jsonScan);
            */
        String scanStr = scan.BSSID + sep + scan.frequency + sep + scan.level + "\n";
        csv = csv + scanStr;
    }
    return csv;
}
项目:WiFi-and-Sensors-Indoor-Positioning    文件:ObtainRssData.java   
private static void getCommonRssAndCoordinateData() {
    /*
     * get RSS data from WiFi. this method is common to online and offline. 
     */
    record_data.delete(0, record_data.length());
    wifiMg.startScan();
    list = wifiMg.getScanResults();
    if (list != null) {
        for (ScanResult scanResult:list) {
            if (routeSSIDSet.contains(scanResult.SSID)) {
                int ssidIndex = routeSSIDSet.indexOf(scanResult.SSID);
                ssidSet[ssidIndex] = scanResult.level;
            }
        }
    }
    for (int i = 0; i < ssidSet.length; i++) {
        record_data.append(routeSSIDSet.get(i) + "," + ssidSet[i] + ",");
    }
    record_data.deleteCharAt(record_data.length()-1);
}
项目:mobility-logger    文件:MainActivity.java   
@Override
public void onReceive(Context context, Intent intent) {
    List<ScanResult> wifiList;
    StringBuilder sb = new StringBuilder();
    wifiList = wifiManager.getScanResults();
    for (int i=0; i<wifiList.size();i++){
        sb.append("\n" + (i+1))
        .append(")\tSSID:").append(wifiList.get(i).SSID)
        .append(", BSSID:").append(wifiList.get(i).BSSID)
        .append(", FREQ:").append(wifiList.get(i).frequency)
        .append(", RSSI:").append(wifiList.get(i).level)
        .append(", ENCR:");
        if (wifiList.get(i).capabilities.length()==0)
            sb.append("[NONE]");
        else sb.append(wifiList.get(i).capabilities);
    }
    TextView hotspotslist = (TextView)findViewById(R.id.hotspotslist);
    hotspotslist.setText(sb);
    TextView nhotspots = (TextView)findViewById(R.id.nhotspots);
    nhotspots.setText(String.valueOf(wifiList.size()));
    if(continuous_wifi_scanning)
        wifiManager.startScan();
}
项目:Wio_Link_Android_App    文件:Step03WifiWioListActivity.java   
private List<ScanResult> getPionWifiList() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
            checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(
                new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
                PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION);
        //After this point you wait for callback in onRequestPermissionsResult(int, String[], int[]) overriden method
        Log.d(TAG, "checking...");
    } else {
        Log.d(TAG, "scaning...");
        getScanningResults();
        //do something, permission was previously granted; or legacy device
    }

    if (scanPionResult == null || scanPionResult.size() == 0) {
        mRlMoreSetting.setVisibility(View.VISIBLE);
    } else {
        mRlMoreSetting.setVisibility(View.GONE);
    }

    return scanPionResult;
}
项目:FlyWoo    文件:CreateConnectionVu.java   
/**
 * 处理扫描到的Wifi列表
 *
 * @param scanResults
 */
private void handleList(List<ScanResult> scanResults) {
    //遍历扫描到的结果
    for (ScanResult wifi : scanResults) {
        String s = wifi.SSID;
        //以ZChat_开头
        if (s.startsWith(WifiConst.WIFI_AP_HEADER)) {
            if (!mList.contains(s)) {//没有添加过
                mList.add(wifi.SSID);
                //添加热点头像
                mSearchView.addApView(wifi);
            }
        }
    }

}
项目:eshow-android    文件:AbWifiUtil.java   
/**
 * 
 * 描述:根据SSID过滤扫描结果.
 * @param context
 * @param bssid
 * @return
 */
public static ScanResult getScanResultsByBSSID(Context context,String bssid) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    ScanResult scanResult = null;
    //开始扫描WiFi
    boolean f = wifiManager.startScan();
    if(!f){
        getScanResultsByBSSID(context,bssid);
    }
    // 得到扫描结果
    List<ScanResult> list = wifiManager.getScanResults();
    if (list != null) {
        for (int i = 0; i < list.size(); i++) {
            // 得到扫描结果
            scanResult = list.get(i);
            if (scanResult.BSSID.equals(bssid)) {
                break;
            }
        }
    }
    return scanResult;
}
项目:DeviceConnect-Android    文件:HVCC2WPairingFragment.java   
/**
 * Check Wifi.
 */
private void searchWifi() {
    final WifiManager wifiManager = getWifiManager();
    if (wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
        mReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                List<ScanResult> results = wifiManager.getScanResults();
                if (results.size() == 0) {
                    return;
                }
                mSSID.setText(results.get(0).SSID);
            }
        };
        getActivity().registerReceiver(mReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    }
    wifiManager.startScan();
}
项目:AILS_Demonstrator    文件:WiFiProfileFactoryAndroidImpl.java   
@Override
public Optional<WiFiProfile> getProfile() {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

    if (wifiManager.getWifiState() != WifiManager.WIFI_STATE_ENABLED) {
        return Optional.absent();
    }

    List<AccessPointMeasurement> accessPointMeasurements = new ArrayList<>();
    for (ScanResult scanResult : wifiManager.getScanResults()) {
        accessPointMeasurements.add(
                new AccessPointMeasurement(
                        new AccessPoint(scanResult.BSSID.getBytes()), scanResult.level
                )
        );
    }
    return Optional.of(new WiFiProfile(new Date(), accessPointMeasurements));
}
项目:Gizwits-SmartBuld_Android    文件:GosMessageHandler.java   
public void run() {
    if (mcContext == null) {
        return;
    }
    newDeviceList.clear();
    List<ScanResult> currentWifiScanResult = NetUtils.getCurrentWifiScanResult(mcContext);
    int flog = 0;
    for (ScanResult scanResult : currentWifiScanResult) {
        String ssid = scanResult.SSID;
        // 获取系统的NotificationManager服务
        nm = (NotificationManager) mcContext.getSystemService(Context.NOTIFICATION_SERVICE);
        if (ssid.contains(GosBaseActivity.SoftAP_Start) && ssid.length() > GosBaseActivity.SoftAP_Start.length()
                && !newDeviceList.toString().contains(ssid)) {
            newDeviceList.add(ssid);
            flog++;
            send(ssid, flog);
        }
    }
    if (mainHandler != null && newDeviceList.size() > 0) {
        mainHandler.sendEmptyMessage(SHOWDIALOG);
    }

    looper.postDelayed(mRunnable, 2000);
}
项目:WiFiAnalyzer    文件:Cache.java   
List<CacheResult> getScanResults() {
    ScanResult current = null;
    int levelTotal = 0;
    int count = 0;
    List<CacheResult> results = new ArrayList<>();
    for (ScanResult scanResult : combineCache()) {
        if (current != null && !scanResult.BSSID.equals(current.BSSID)) {
            CacheResult cacheResult = getCacheResult(current, levelTotal, count);
            results.add(cacheResult);
            count = 0;
            levelTotal = 0;
        }
        current = scanResult;
        count++;
        levelTotal += scanResult.level;
    }
    if (current != null) {
        results.add(getCacheResult(current, levelTotal, count));
    }
    return results;
}
项目:WiFiAnalyzer    文件:Scanner.java   
private void performWiFiScan() {
    List<ScanResult> scanResults = Collections.emptyList();
    WifiInfo wifiInfo = null;
    List<WifiConfiguration> configuredNetworks = null;
    try {
        if (!wifiManager.isWifiEnabled()) {
            wifiManager.setWifiEnabled(true);
        }
        if (wifiManager.startScan()) {
            scanResults = wifiManager.getScanResults();
        }
        wifiInfo = wifiManager.getConnectionInfo();
        configuredNetworks = wifiManager.getConfiguredNetworks();
    } catch (Exception e) {
        // critical error: set to no results and do not die
    }
    cache.add(scanResults);
    wiFiData = transformer.transformToWiFiData(cache.getScanResults(), wifiInfo, configuredNetworks);
}
项目:Android-WiFiBeacon-demo    文件:AveragedScanResult.java   
public void averageRssi(@NonNull ScanResult newResult) {
    if (Build.VERSION.SDK_INT >= 17 && newResult.timestamp == scanResult.timestamp) {
        return;
    }
    int newRssi = newResult.level;
    newResult.level = scanResult.level;
    scanResult = newResult;
    long nowSeen = System.currentTimeMillis();
    long age = nowSeen - seen;

    if (seen > 0 && age > 0 && age < MAX_AGE / 2) {
        // Average the RSSI with previously seen instances of this scan result
        double alpha = 0.5 - (double) age / (double) MAX_AGE;
        scanResult.level = (int) ((double) newRssi * (1 - alpha) + (double) scanResult.level * alpha);
    } else {
        scanResult.level = newRssi;
    }
    seen = nowSeen;
}
项目:EricUtils    文件:NetworkUtils.java   
/**
 *
 * @param context describes the context of the execution.
 * @param searchFirst if true, it will force a scan, else, it will use the current device scan.
 * @return the list of SSID's in the network.
 */
public static List<String> getWifiSSIDs(Context context,Boolean searchFirst){
    WifiManager mgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    List<ScanResult> results;
    List<String> returnValues = new ArrayList<>();
    if(searchFirst){
        mgr.startScan();
        results = mgr.getScanResults();
    }else{
        results = mgr.getScanResults();
    }
    for(ScanResult r : results){
        returnValues.add(r.SSID);
    }
    return returnValues;
}
项目:Android-WiFiBeacon-demo    文件:ProximityScanner.java   
@Override
public void onScanResultsReceived(List<ScanResult> results) {
    if (rangingListener != null) {
        List<ScanResult> processedResults = new ArrayList<>();
        for (int i = 0, resultsSize = results.size(); i < resultsSize; i++) {
            ScanResult result = results.get(i);
            if (ragingFilter == null || ragingFilter.matchesStart(result)) {
                AveragedScanResult oldResult = averagedResults.get(result.BSSID);
                if (oldResult == null) {
                    oldResult = new AveragedScanResult(result);
                    averagedResults.put(result.BSSID, oldResult);
                } else {
                    oldResult.averageRssi(result);
                }
                processedResults.add(oldResult.getScanResult());
            }
        }
        Collections.sort(processedResults, SCAN_RESULT_COMPARATOR);
        rangingListener.onAPsDiscovered(processedResults);
    }
}