use of android.net.wifi.ScanResult in project android_frameworks_base by crdroidandroid.
the class WifiTracker method fetchScanResults.
private Collection<ScanResult> fetchScanResults() {
mScanId++;
final List<ScanResult> newResults = mWifiManager.getScanResults();
if (newResults == null) {
return null;
}
for (ScanResult newResult : newResults) {
if (newResult.SSID == null || newResult.SSID.isEmpty()) {
continue;
}
mScanResultCache.put(newResult.BSSID, newResult);
mSeenBssids.put(newResult.BSSID, mScanId);
}
if (mScanId > NUM_SCANS_TO_CONFIRM_AP_LOSS) {
if (DBG)
Log.d(TAG, "------ Dumping SSIDs that were expired on this scan ------");
Integer threshold = mScanId - NUM_SCANS_TO_CONFIRM_AP_LOSS;
for (Iterator<Map.Entry<String, Integer>> it = mSeenBssids.entrySet().iterator(); it.hasNext(); ) /* nothing */
{
Map.Entry<String, Integer> e = it.next();
if (e.getValue() < threshold) {
ScanResult result = mScanResultCache.get(e.getKey());
if (DBG)
Log.d(TAG, "Removing " + e.getKey() + ":(" + result.SSID + ")");
mScanResultCache.remove(e.getKey());
it.remove();
}
}
if (DBG)
Log.d(TAG, "---- Done Dumping SSIDs that were expired on this scan ----");
}
return mScanResultCache.values();
}
use of android.net.wifi.ScanResult in project PhoneProfilesPlus by henrichg.
the class WifiScanJob method fillScanResults.
static void fillScanResults(Context context) {
List<WifiSSIDData> scanResults = new ArrayList<>();
boolean save = false;
if (wifi == null)
wifi = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (Permissions.checkLocation(context)) {
List<ScanResult> _scanResults = wifi.getScanResults();
PPApplication.logE("%%%% WifiScanJob.fillScanResults", "_scanResults=" + _scanResults);
if (_scanResults != null) {
// PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
// boolean isScreenOn = pm.isScreenOn();
// PPApplication.logE("%%%% WifiScanJob.fillScanResults", "isScreenOn="+isScreenOn);
// if ((android.os.Build.VERSION.SDK_INT < 21) || (_scanResults.size() > 0) || isScreenOn) {
save = true;
scanResults.clear();
for (ScanResult device : _scanResults) {
boolean found = false;
for (WifiSSIDData _device : scanResults) {
if (_device.bssid.equals(device.BSSID)) {
found = true;
break;
}
}
if (!found) {
scanResults.add(new WifiSSIDData(device.SSID, device.BSSID, false));
}
}
// }
} else
PPApplication.logE("%%%% WifiScanJob.fillScanResults", "_scanResults=null");
} else
save = true;
if (save)
saveScanResults(context, scanResults);
}
use of android.net.wifi.ScanResult in project wiseasily by eFishery.
the class ScanWifi method onAPChanged.
@Override
public void onAPChanged(List<ScanResult> scanResults) {
if (callback != null) {
List<ScanResult> scanResultsFilter = new ArrayList<>();
for (ScanResult scanResult : scanResults) {
if (scanFilter == null || scanFilter.matchesStart(scanResult)) {
scanResultsFilter.add(scanResult);
}
}
callback.onAPChanged(scanResultsFilter);
}
}
use of android.net.wifi.ScanResult in project BaseProject by fly803.
the class AppNetworkMgr method getScanResultsByBSSID.
/**
* 过滤扫描结果
* @param context
* @param bssid
* @return
*/
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;
}
use of android.net.wifi.ScanResult in project android_packages_apps_Settings by DirtyUnicorns.
the class WifiStatusTest method handleScanResultsAvailable.
private void handleScanResultsAvailable() {
List<ScanResult> list = mWifiManager.getScanResults();
StringBuffer scanList = new StringBuffer();
if (list != null) {
for (int i = list.size() - 1; i >= 0; i--) {
final ScanResult scanResult = list.get(i);
if (scanResult == null) {
continue;
}
if (TextUtils.isEmpty(scanResult.SSID)) {
continue;
}
scanList.append(scanResult.SSID + " ");
}
}
mScanList.setText(scanList);
}
Aggregations