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

Commit 35f1fcdc authored by Etan Cohen's avatar Etan Cohen
Browse files

[AWARE] Allow setPMK API

Allowing configuration of the PMK is required for any PK-based protocols
which operate OOB.

Bug: 143956273
Bug: 111446262
Test: test android.net.wifi.aware
Change-Id: Iccd9739901116399518f278e7d9c9992c1507f3f
parent 2c6c2040
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -30356,6 +30356,7 @@ package android.net.wifi.aware {
  public static final class WifiAwareNetworkSpecifier.Builder {
    ctor public WifiAwareNetworkSpecifier.Builder(@NonNull android.net.wifi.aware.DiscoverySession, @NonNull android.net.wifi.aware.PeerHandle);
    method @NonNull public android.net.wifi.aware.WifiAwareNetworkSpecifier build();
    method @NonNull public android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder setPmk(@NonNull byte[]);
    method @NonNull public android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder setPort(@IntRange(from=0, to=65535) int);
    method @NonNull public android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder setPskPassphrase(@NonNull String);
    method @NonNull public android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder setTransportProtocol(@IntRange(from=0, to=255) int);
+0 −4
Original line number Diff line number Diff line
@@ -5091,10 +5091,6 @@ package android.net.wifi.aware {
    method @Deprecated public android.net.NetworkSpecifier createNetworkSpecifierPmk(@NonNull android.net.wifi.aware.PeerHandle, @NonNull byte[]);
  }
  public static final class WifiAwareNetworkSpecifier.Builder {
    method @NonNull public android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder setPmk(@NonNull byte[]);
  }
  public class WifiAwareSession implements java.lang.AutoCloseable {
    method public android.net.NetworkSpecifier createNetworkSpecifierPmk(int, @NonNull byte[], @NonNull byte[]);
  }
+5 −7
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.net.wifi.aware.WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_

import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.net.NetworkSpecifier;
import android.os.Parcel;
import android.os.Parcelable;
@@ -337,7 +336,8 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
         * Configure the PSK Passphrase for the Wi-Fi Aware connection being requested. This method
         * is optional - if not called, then an Open (unencrypted) connection will be created.
         *
         * @param pskPassphrase The (optional) passphrase to be used to encrypt the link.
         * @param pskPassphrase The (optional) passphrase to be used to encrypt the link. Use the
         *                      {@link #setPmk(byte[])} to specify a PMK.
         * @return the current {@link Builder} builder, enabling chaining of builder
         *         methods.
         */
@@ -358,9 +358,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
         *            specify a Passphrase.
         * @return the current {@link Builder} builder, enabling chaining of builder
         *         methods.
         * @hide
         */
        @SystemApi
        public @NonNull Builder setPmk(@NonNull byte[] pmk) {
            if (!WifiAwareUtils.validatePmk(pmk)) {
                throw new IllegalArgumentException("PMK must 32 bytes");
@@ -377,7 +375,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
         * <ul>
         *     <li>The server device must be the Publisher device!
         *     <li>The port information can only be specified on secure links, specified using
         *     {@link #setPskPassphrase(String)}.
         *     {@link #setPskPassphrase(String)} or {@link #setPmk(byte[])}.
         * </ul>
         *
         * @param port A positive integer indicating the port to be used for communication.
@@ -400,7 +398,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
         * <ul>
         *     <li>The server device must be the Publisher device!
         *     <li>The transport protocol information can only be specified on secure links,
         *     specified using {@link #setPskPassphrase(String)}.
         *     specified using {@link #setPskPassphrase(String)} or {@link #setPmk(byte[])}.
         * </ul>
         * The transport protocol number is assigned by the Internet Assigned Numbers Authority
         * (IANA) https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml.
@@ -426,7 +424,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
         * {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE}.
         * <p> The default builder constructor will initialize a NetworkSpecifier which requests an
         * open (non-encrypted) link. To request an encrypted link use the
         * {@link #setPskPassphrase(String)} builder method.
         * {@link #setPskPassphrase(String)} or {@link #setPmk(byte[])} builder methods.
         *
         * @return A {@link NetworkSpecifier} to be used to construct
         * {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(NetworkSpecifier)} to pass