Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2892ba66 authored by Etan Cohen's avatar Etan Cohen
Browse files

[RTT2] System API for a Responder Configuration

The Responder Configuration is an abstracted specification of the peer
RTT Responder (to which we initiate an RTT operation).

The Responder is abstracted from a ScanResult (for an AP) or a Wi-Fi
Aware PeerHandle or MAC address. Utility methods are provided.

The Responder configuration is the underlying representation used by
the RTT manager and service to communicate infomration on RTT targets.
This API thus does not provide any additional permission or backdoor
hooks to the RTT functionality. It exposes a lower level utility
representation of the data. We may choose to make this more widely
available in the future if necessary.

Bug: 65108607
Test: builds
Change-Id: I620d8e725ad61792b7604ff1355adb1b0ef38ad1
parent a0688e03
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -3117,6 +3117,43 @@ package android.net.wifi.aware {

package android.net.wifi.rtt {

  public static final class RangingRequest.Builder {
    method public android.net.wifi.rtt.RangingRequest.Builder addResponder(android.net.wifi.rtt.ResponderConfig);
  }

  public final class ResponderConfig implements android.os.Parcelable {
    ctor public ResponderConfig(android.net.MacAddress, int, boolean, int, int, int, int, int);
    ctor public ResponderConfig(android.net.wifi.aware.PeerHandle, int, boolean, int, int, int, int, int);
    method public int describeContents();
    method public static android.net.wifi.rtt.ResponderConfig fromScanResult(android.net.wifi.ScanResult);
    method public static android.net.wifi.rtt.ResponderConfig fromWifiAwarePeerHandleWithDefaults(android.net.wifi.aware.PeerHandle);
    method public static android.net.wifi.rtt.ResponderConfig fromWifiAwarePeerMacAddressWithDefaults(android.net.MacAddress);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int CHANNEL_WIDTH_160MHZ = 3; // 0x3
    field public static final int CHANNEL_WIDTH_20MHZ = 0; // 0x0
    field public static final int CHANNEL_WIDTH_40MHZ = 1; // 0x1
    field public static final int CHANNEL_WIDTH_80MHZ = 2; // 0x2
    field public static final int CHANNEL_WIDTH_80MHZ_PLUS_MHZ = 4; // 0x4
    field public static final android.os.Parcelable.Creator<android.net.wifi.rtt.ResponderConfig> CREATOR;
    field public static final int PREAMBLE_HT = 1; // 0x1
    field public static final int PREAMBLE_LEGACY = 0; // 0x0
    field public static final int PREAMBLE_VHT = 2; // 0x2
    field public static final int RESPONDER_AP = 0; // 0x0
    field public static final int RESPONDER_AWARE = 4; // 0x4
    field public static final int RESPONDER_P2P_CLIENT = 3; // 0x3
    field public static final int RESPONDER_P2P_GO = 2; // 0x2
    field public static final int RESPONDER_STA = 1; // 0x1
    field public final int centerFreq0;
    field public final int centerFreq1;
    field public final int channelWidth;
    field public final int frequency;
    field public final android.net.MacAddress macAddress;
    field public final android.net.wifi.aware.PeerHandle peerHandle;
    field public final int preamble;
    field public final int responderType;
    field public final boolean supports80211mc;
  }

  public class WifiRttManager {
    method public void cancelRanging(android.os.WorkSource);
    method public void startRanging(android.os.WorkSource, android.net.wifi.rtt.RangingRequest, android.net.wifi.rtt.RangingResultCallback, android.os.Handler);
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.net.wifi.rtt;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.net.MacAddress;
import android.net.wifi.ScanResult;
import android.net.wifi.aware.AttachCallback;
@@ -206,6 +207,7 @@ public final class RangingRequest implements Parcelable {
         *
         * @hide
         */
        @SystemApi
        public Builder addResponder(@NonNull ResponderConfig responder) {
            if (responder == null) {
                throw new IllegalArgumentException("Null Responder!");
+6 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.net.wifi.rtt;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.net.MacAddress;
import android.net.wifi.ScanResult;
import android.net.wifi.aware.PeerHandle;
@@ -35,8 +36,9 @@ import java.util.Objects;
 * A Responder configuration may be constructed from a {@link ScanResult} or manually (with the
 * data obtained out-of-band from a peer).
 *
 * @hide (@SystemApi)
 * @hide
 */
@SystemApi
public final class ResponderConfig implements Parcelable {
    private static final int AWARE_BAND_2_DISCOVERY_CHANNEL = 2437;

@@ -290,7 +292,7 @@ public final class ResponderConfig implements Parcelable {
        MacAddress macAddress = MacAddress.fromString(scanResult.BSSID);
        int responderType = RESPONDER_AP;
        boolean supports80211mc = scanResult.is80211mcResponder();
        int channelWidth = translcateScanResultChannelWidth(scanResult.channelWidth);
        int channelWidth = translateScanResultChannelWidth(scanResult.channelWidth);
        int frequency = scanResult.frequency;
        int centerFreq0 = scanResult.centerFreq0;
        int centerFreq1 = scanResult.centerFreq1;
@@ -454,7 +456,7 @@ public final class ResponderConfig implements Parcelable {
    }

    /** @hide */
    static int translcateScanResultChannelWidth(int scanResultChannelWidth) {
    static int translateScanResultChannelWidth(int scanResultChannelWidth) {
        switch (scanResultChannelWidth) {
            case ScanResult.CHANNEL_WIDTH_20MHZ:
                return CHANNEL_WIDTH_20MHZ;
@@ -468,7 +470,7 @@ public final class ResponderConfig implements Parcelable {
                return CHANNEL_WIDTH_80MHZ_PLUS_MHZ;
            default:
                throw new IllegalArgumentException(
                        "translcateScanResultChannelWidth: bad " + scanResultChannelWidth);
                        "translateScanResultChannelWidth: bad " + scanResultChannelWidth);
        }
    }
}