android.net.wifi.rtt.RangingRequest Java Examples

The following examples show how to use android.net.wifi.rtt.RangingRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccessPointRangingResultsActivity.java    From connectivity-samples with Apache License 2.0 6 votes vote down vote up
private void startRangingRequest() {
    // Permission for fine location should already be granted via MainActivity (you can't get
    // to this class unless you already have permission. If they get to this class, then disable
    // fine location permission, we kick them back to main activity.
    if (ActivityCompat.checkSelfPermission(this, permission.ACCESS_FINE_LOCATION)
            != PackageManager.PERMISSION_GRANTED) {
        finish();
    }

    mNumberOfRangeRequests++;

    RangingRequest rangingRequest =
            new RangingRequest.Builder().addAccessPoint(mScanResult).build();

    mWifiRttManager.startRanging(
            rangingRequest, getApplication().getMainExecutor(), mRttRangingResultCallback);
}
 
Example #2
Source File: MainActivity.java    From connectivity-samples with Apache License 2.0 6 votes vote down vote up
private List<ScanResult> find80211mcSupportedAccessPoints(
        @NonNull List<ScanResult> originalList) {
    List<ScanResult> newList = new ArrayList<>();

    for (ScanResult scanResult : originalList) {

        if (scanResult.is80211mcResponder()) {
            newList.add(scanResult);
        }

        if (newList.size() >= RangingRequest.getMaxPeers()) {
            break;
        }
    }
    return newList;
}
 
Example #3
Source File: RttRangingManager.java    From android-rttmanager-sample with Apache License 2.0 6 votes vote down vote up
public Single<List<RangingResult>> startRanging(
        @NonNull final ScanResult scanResult) {
    return Single.create(emitter -> {
        final RangingRequest request = new RangingRequest.Builder()
                .addAccessPoint(scanResult)
                .build();
        final RangingResultCallback callback = new RangingResultCallback() {
            @Override
            public void onRangingFailure(final int i) {
                emitter.onError(new RuntimeException("The WiFi-Ranging failed with error code: " + i));
            }

            @Override
            public void onRangingResults(final List<RangingResult> list) {
                emitter.onSuccess(list);
            }
        };
        rttManager.startRanging(request, mainExecutor, callback);
    });
}
 
Example #4
Source File: AccessPointRangingResultsActivity.java    From android-WifiRttScan with Apache License 2.0 6 votes vote down vote up
private void startRangingRequest() {
    // Permission for fine location should already be granted via MainActivity (you can't get
    // to this class unless you already have permission. If they get to this class, then disable
    // fine location permission, we kick them back to main activity.
    if (ActivityCompat.checkSelfPermission(this, permission.ACCESS_FINE_LOCATION)
            != PackageManager.PERMISSION_GRANTED) {
        finish();
    }

    mNumberOfRangeRequests++;

    RangingRequest rangingRequest =
            new RangingRequest.Builder().addAccessPoint(mScanResult).build();

    mWifiRttManager.startRanging(
            rangingRequest, getApplication().getMainExecutor(), mRttRangingResultCallback);
}
 
Example #5
Source File: MainActivity.java    From android-WifiRttScan with Apache License 2.0 6 votes vote down vote up
private List<ScanResult> find80211mcSupportedAccessPoints(
        @NonNull List<ScanResult> originalList) {
    List<ScanResult> newList = new ArrayList<>();

    for (ScanResult scanResult : originalList) {

        if (scanResult.is80211mcResponder()) {
            newList.add(scanResult);
        }

        if (newList.size() >= RangingRequest.getMaxPeers()) {
            break;
        }
    }
    return newList;
}
 
Example #6
Source File: LocationRangingService.java    From WiFi-RTT-Trilateration with MIT License 5 votes vote down vote up
@SuppressLint("MissingPermission")
public void onReceive(Context context, Intent intent) {
    List<ScanResult> scanResults = mWifiManager.getScanResults();
    if (scanResults != null) {

        WifiRttAPs = new ArrayList<>();
        for (ScanResult scanResult : scanResults) {
            if (scanResult.is80211mcResponder())
                WifiRttAPs.add(scanResult);
            if (WifiRttAPs.size() >= RangingRequest.getMaxPeers()) {
                break;
            }
        }

        showMessage(scanResults.size()
                + " APs discovered, "
                + WifiRttAPs.size()
                + " RTT capable.");
        for (ScanResult wifiRttAP : WifiRttAPs) {
            showMessage("AP Supporting RTT: " + wifiRttAP.SSID + " (" + wifiRttAP.BSSID + ")");
        }
        //  Start ranging
        if (WifiRttAPs.size() < configuration.getConfiguration().size())
            showMessage("Did not find enough RTT enabled APs.  Found: " + WifiRttAPs.size());
        else {
            startRangingRequest(WifiRttAPs);
        }
    }
}
 
Example #7
Source File: LocationRangingService.java    From WiFi-RTT-Trilateration with MIT License 5 votes vote down vote up
@SuppressLint("MissingPermission")
private void startRangingRequest(List<ScanResult> scanResults) {
    RangingRequest rangingRequest =
            new RangingRequest.Builder().addAccessPoints(scanResults).build();

    mWifiRttManager.startRanging(
            rangingRequest, getApplication().getMainExecutor(), mRttRangingResultCallback);
}