[NAN]: API update - consolidate Puslish|Subscribe Data+Subscribe -> Config
Simplify configuration and consolidate structures whose difference
wasn't very clear.
(cherry-pick of e4c50de75273efaec4e9e8db6174e0bfc07d3105,
Change-Id: I0651cade71eb146d9ea9219baf6d2253588db3de)
Bug: 27122760
Change-Id: I6320bd4c960e4473b4bf3c28e54a7ba492fa2cf9
(cherry picked from commit 581a4f7b31e3ccefce6c022582fd99ba0313b73c)
diff --git a/Android.mk b/Android.mk
index 27cf90c..1750c7c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -536,10 +536,8 @@
frameworks/base/media/java/android/media/browse/MediaBrowser.aidl \
frameworks/base/wifi/java/android/net/wifi/ScanSettings.aidl \
frameworks/base/wifi/java/android/net/wifi/nan/ConfigRequest.aidl \
- frameworks/base/wifi/java/android/net/wifi/nan/PublishData.aidl \
- frameworks/base/wifi/java/android/net/wifi/nan/SubscribeData.aidl \
- frameworks/base/wifi/java/android/net/wifi/nan/PublishSettings.aidl \
- frameworks/base/wifi/java/android/net/wifi/nan/SubscribeSettings.aidl \
+ frameworks/base/wifi/java/android/net/wifi/nan/PublishConfig.aidl \
+ frameworks/base/wifi/java/android/net/wifi/nan/SubscribeConfig.aidl \
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pInfo.aidl \
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.aidl \
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pConfig.aidl \
diff --git a/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl b/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl
index 5b4284c..911d13c 100644
--- a/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl
+++ b/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl
@@ -21,10 +21,8 @@
import android.net.wifi.nan.ConfigRequest;
import android.net.wifi.nan.IWifiNanEventListener;
import android.net.wifi.nan.IWifiNanSessionListener;
-import android.net.wifi.nan.PublishData;
-import android.net.wifi.nan.PublishSettings;
-import android.net.wifi.nan.SubscribeData;
-import android.net.wifi.nan.SubscribeSettings;
+import android.net.wifi.nan.PublishConfig;
+import android.net.wifi.nan.SubscribeConfig;
/**
* Interface that WifiNanService implements
@@ -40,10 +38,8 @@
// session API
int createSession(int clientId, in IWifiNanSessionListener listener, int events);
- void publish(int clientId, int sessionId, in PublishData publishData,
- in PublishSettings publishSettings);
- void subscribe(int clientId, int sessionId, in SubscribeData subscribeData,
- in SubscribeSettings subscribeSettings);
+ void publish(int clientId, int sessionId, in PublishConfig publishConfig);
+ void subscribe(int clientId, int sessionId, in SubscribeConfig subscribeConfig);
void sendMessage(int clientId, int sessionId, int peerId, in byte[] message, int messageLength,
int messageId);
void stopSession(int clientId, int sessionId);
diff --git a/wifi/java/android/net/wifi/nan/SubscribeSettings.aidl b/wifi/java/android/net/wifi/nan/PublishConfig.aidl
similarity index 95%
copy from wifi/java/android/net/wifi/nan/SubscribeSettings.aidl
copy to wifi/java/android/net/wifi/nan/PublishConfig.aidl
index 44849bc..5f66d16 100644
--- a/wifi/java/android/net/wifi/nan/SubscribeSettings.aidl
+++ b/wifi/java/android/net/wifi/nan/PublishConfig.aidl
@@ -16,4 +16,4 @@
package android.net.wifi.nan;
-parcelable SubscribeSettings;
+parcelable PublishConfig;
diff --git a/wifi/java/android/net/wifi/nan/PublishData.java b/wifi/java/android/net/wifi/nan/PublishConfig.java
similarity index 63%
rename from wifi/java/android/net/wifi/nan/PublishData.java
rename to wifi/java/android/net/wifi/nan/PublishConfig.java
index 80119eb..cf5251c 100644
--- a/wifi/java/android/net/wifi/nan/PublishData.java
+++ b/wifi/java/android/net/wifi/nan/PublishConfig.java
@@ -22,13 +22,29 @@
import java.util.Arrays;
/**
- * Defines the data for a NAN publish session. Built using
- * {@link PublishData.Builder}. Publish is done using
- * {@link WifiNanManager#publish(PublishData, PublishSettings, WifiNanSessionListener, int)}
- * or {@link WifiNanPublishSession#publish(PublishData, PublishSettings)}.
+ * Defines the configuration of a NAN publish session. Built using
+ * {@link PublishConfig.Builder}. Publish is done using
+ * {@link WifiNanManager#publish(PublishConfig, WifiNanSessionListener, int)} or
+ * {@link WifiNanPublishSession#publish(PublishConfig)}.
+ *
* @hide PROPOSED_NAN_API
*/
-public class PublishData implements Parcelable {
+public class PublishConfig implements Parcelable {
+ /**
+ * Defines an unsolicited publish session - i.e. a publish session where
+ * publish packets are transmitted over-the-air. Configuration is done using
+ * {@link PublishConfig.Builder#setPublishType(int)}.
+ */
+ public static final int PUBLISH_TYPE_UNSOLICITED = 0;
+
+ /**
+ * Defines a solicited publish session - i.e. a publish session where
+ * publish packets are not transmitted over-the-air and the device listens
+ * and matches to transmitted subscribe packets. Configuration is done using
+ * {@link PublishConfig.Builder#setPublishType(int)}.
+ */
+ public static final int PUBLISH_TYPE_SOLICITED = 1;
+
/**
* @hide
*/
@@ -64,9 +80,24 @@
*/
public final byte[] mRxFilter;
- private PublishData(String serviceName, byte[] serviceSpecificInfo,
+ /**
+ * @hide
+ */
+ public final int mPublishType;
+
+ /**
+ * @hide
+ */
+ public final int mPublishCount;
+
+ /**
+ * @hide
+ */
+ public final int mTtlSec;
+
+ private PublishConfig(String serviceName, byte[] serviceSpecificInfo,
int serviceSpecificInfoLength, byte[] txFilter, int txFilterLength, byte[] rxFilter,
- int rxFilterLength) {
+ int rxFilterLength, int publishType, int publichCount, int ttlSec) {
mServiceName = serviceName;
mServiceSpecificInfoLength = serviceSpecificInfoLength;
mServiceSpecificInfo = serviceSpecificInfo;
@@ -74,17 +105,21 @@
mTxFilter = txFilter;
mRxFilterLength = rxFilterLength;
mRxFilter = rxFilter;
+ mPublishType = publishType;
+ mPublishCount = publichCount;
+ mTtlSec = ttlSec;
}
@Override
public String toString() {
- return "PublishData [mServiceName='" + mServiceName + "', mServiceSpecificInfo='"
+ return "PublishConfig [mServiceName='" + mServiceName + "', mServiceSpecificInfo='"
+ (new String(mServiceSpecificInfo, 0, mServiceSpecificInfoLength))
+ "', mTxFilter="
+ (new TlvBufferUtils.TlvIterable(0, 1, mTxFilter, mTxFilterLength)).toString()
+ ", mRxFilter="
+ (new TlvBufferUtils.TlvIterable(0, 1, mRxFilter, mRxFilterLength)).toString()
- + "']";
+ + ", mPublishType=" + mPublishType + ", mPublishCount=" + mPublishCount
+ + ", mTtlSec=" + mTtlSec + "']";
}
@Override
@@ -92,7 +127,6 @@
return 0;
}
-
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mServiceName);
@@ -108,16 +142,19 @@
if (mRxFilterLength != 0) {
dest.writeByteArray(mRxFilter, 0, mRxFilterLength);
}
+ dest.writeInt(mPublishType);
+ dest.writeInt(mPublishCount);
+ dest.writeInt(mTtlSec);
}
- public static final Creator<PublishData> CREATOR = new Creator<PublishData>() {
+ public static final Creator<PublishConfig> CREATOR = new Creator<PublishConfig>() {
@Override
- public PublishData[] newArray(int size) {
- return new PublishData[size];
+ public PublishConfig[] newArray(int size) {
+ return new PublishConfig[size];
}
@Override
- public PublishData createFromParcel(Parcel in) {
+ public PublishConfig createFromParcel(Parcel in) {
String serviceName = in.readString();
int ssiLength = in.readInt();
byte[] ssi = new byte[ssiLength];
@@ -134,9 +171,11 @@
if (rxFilterLength != 0) {
in.readByteArray(rxFilter);
}
-
- return new PublishData(serviceName, ssi, ssiLength, txFilter, txFilterLength, rxFilter,
- rxFilterLength);
+ int publishType = in.readInt();
+ int publishCount = in.readInt();
+ int ttlSec = in.readInt();
+ return new PublishConfig(serviceName, ssi, ssiLength, txFilter, txFilterLength,
+ rxFilter, rxFilterLength, publishType, publishCount, ttlSec);
}
};
@@ -146,11 +185,11 @@
return true;
}
- if (!(o instanceof PublishData)) {
+ if (!(o instanceof PublishConfig)) {
return false;
}
- PublishData lhs = (PublishData) o;
+ PublishConfig lhs = (PublishConfig) o;
if (!mServiceName.equals(lhs.mServiceName)
|| mServiceSpecificInfoLength != lhs.mServiceSpecificInfoLength
@@ -189,7 +228,8 @@
return false; // invalid != invalid
}
- return true;
+ return mPublishType == lhs.mPublishType && mPublishCount == lhs.mPublishCount
+ && mTtlSec == lhs.mTtlSec;
}
@Override
@@ -203,12 +243,15 @@
result = 31 * result + Arrays.hashCode(mTxFilter);
result = 31 * result + mRxFilterLength;
result = 31 * result + Arrays.hashCode(mRxFilter);
+ result = 31 * result + mPublishType;
+ result = 31 * result + mPublishCount;
+ result = 31 * result + mTtlSec;
return result;
}
/**
- * Builder used to build {@link PublishData} objects.
+ * Builder used to build {@link PublishConfig} objects.
*/
public static final class Builder {
private String mServiceName;
@@ -218,6 +261,9 @@
private byte[] mTxFilter = new byte[0];
private int mRxFilterLength;
private byte[] mRxFilter = new byte[0];
+ private int mPublishType;
+ private int mPublishCount;
+ private int mTtlSec;
/**
* Specify the service name of the publish session. The actual on-air
@@ -260,7 +306,7 @@
/**
* Specify service specific information for the publish session - same
- * as {@link PublishData.Builder#setServiceSpecificInfo(byte[], int)}
+ * as {@link PublishConfig.Builder#setServiceSpecificInfo(byte[], int)}
* but obtaining the data from a String.
*
* @param serviceSpecificInfoStr The service specific information string
@@ -277,8 +323,8 @@
/**
* The transmit filter for an active publish session
- * {@link PublishSettings.Builder#setPublishType(int)} and
- * {@link PublishSettings#PUBLISH_TYPE_UNSOLICITED}. Included in
+ * {@link PublishConfig.Builder#setPublishType(int)} and
+ * {@link PublishConfig#PUBLISH_TYPE_UNSOLICITED}. Included in
* transmitted publish packets and used by receivers (subscribers) to
* determine whether they match - in addition to just relying on the
* service name.
@@ -305,8 +351,8 @@
/**
* The transmit filter for a passive publish session
- * {@link PublishSettings.Builder#setPublishType(int)} and
- * {@link PublishSettings#PUBLISH_TYPE_SOLICITED}. Used by the publisher
+ * {@link PublishConfig.Builder#setPublishType(int)} and
+ * {@link PublishConfig#PUBLISH_TYPE_SOLICITED}. Used by the publisher
* to determine whether they match transmitted subscriber packets
* (active subscribers) - in addition to just relying on the service
* name.
@@ -332,12 +378,73 @@
}
/**
- * Build {@link PublishData} given the current requests made on the
+ * Sets the type of the publish session: solicited (aka active - publish
+ * packets are transmitted over-the-air), or unsolicited (aka passive -
+ * no publish packets are transmitted, a match is made against an active
+ * subscribe session whose packets are transmitted over-the-air).
+ *
+ * @param publishType Publish session type: solicited (
+ * {@link PublishConfig#PUBLISH_TYPE_SOLICITED}) or
+ * unsolicited (
+ * {@link PublishConfig#PUBLISH_TYPE_UNSOLICITED}).
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setPublishType(int publishType) {
+ if (publishType < PUBLISH_TYPE_UNSOLICITED || publishType > PUBLISH_TYPE_SOLICITED) {
+ throw new IllegalArgumentException("Invalid publishType - " + publishType);
+ }
+ mPublishType = publishType;
+ return this;
+ }
+
+ /**
+ * Sets the number of times a solicited (
+ * {@link PublishConfig.Builder#setPublishType(int)}) publish session
+ * will transmit a packet. When the count is reached an event will be
+ * generated for {@link WifiNanSessionListener#onPublishTerminated(int)}
+ * with reason={@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
+ *
+ * @param publishCount Number of publish packets to transmit.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setPublishCount(int publishCount) {
+ if (publishCount < 0) {
+ throw new IllegalArgumentException("Invalid publishCount - must be non-negative");
+ }
+ mPublishCount = publishCount;
+ return this;
+ }
+
+ /**
+ * Sets the time interval (in seconds) a solicited (
+ * {@link PublishConfig.Builder#setPublishCount(int)}) publish session
+ * will be alive - i.e. transmitting a packet. When the TTL is reached
+ * an event will be generated for
+ * {@link WifiNanSessionListener#onPublishTerminated(int)} with reason=
+ * {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
+ *
+ * @param ttlSec Lifetime of a publish session in seconds.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setTtlSec(int ttlSec) {
+ if (ttlSec < 0) {
+ throw new IllegalArgumentException("Invalid ttlSec - must be non-negative");
+ }
+ mTtlSec = ttlSec;
+ return this;
+ }
+
+ /**
+ * Build {@link PublishConfig} given the current requests made on the
* builder.
*/
- public PublishData build() {
- return new PublishData(mServiceName, mServiceSpecificInfo, mServiceSpecificInfoLength,
- mTxFilter, mTxFilterLength, mRxFilter, mRxFilterLength);
+ public PublishConfig build() {
+ return new PublishConfig(mServiceName, mServiceSpecificInfo, mServiceSpecificInfoLength,
+ mTxFilter, mTxFilterLength, mRxFilter, mRxFilterLength, mPublishType,
+ mPublishCount, mTtlSec);
}
}
}
diff --git a/wifi/java/android/net/wifi/nan/PublishData.aidl b/wifi/java/android/net/wifi/nan/PublishData.aidl
deleted file mode 100644
index 15e4ddf..0000000
--- a/wifi/java/android/net/wifi/nan/PublishData.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.nan;
-
-parcelable PublishData;
diff --git a/wifi/java/android/net/wifi/nan/PublishSettings.aidl b/wifi/java/android/net/wifi/nan/PublishSettings.aidl
deleted file mode 100644
index ff69293..0000000
--- a/wifi/java/android/net/wifi/nan/PublishSettings.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.nan;
-
-parcelable PublishSettings;
diff --git a/wifi/java/android/net/wifi/nan/PublishSettings.java b/wifi/java/android/net/wifi/nan/PublishSettings.java
deleted file mode 100644
index bbc5340..0000000
--- a/wifi/java/android/net/wifi/nan/PublishSettings.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.nan;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Defines the settings (configuration) for a NAN publish session. Built using
- * {@link PublishSettings.Builder}. Publish is done using
- * {@link WifiNanManager#publish(PublishData, PublishSettings, WifiNanSessionListener, int)}
- * or {@link WifiNanPublishSession#publish(PublishData, PublishSettings)}.
- *
- * @hide PROPOSED_NAN_API
- */
-public class PublishSettings implements Parcelable {
-
- /**
- * Defines an unsolicited publish session - i.e. a publish session where
- * publish packets are transmitted over-the-air. Configuration is done using
- * {@link PublishSettings.Builder#setPublishType(int)}.
- */
- public static final int PUBLISH_TYPE_UNSOLICITED = 0;
-
- /**
- * Defines a solicited publish session - i.e. a publish session where
- * publish packets are not transmitted over-the-air and the device listens
- * and matches to transmitted subscribe packets. Configuration is done using
- * {@link PublishSettings.Builder#setPublishType(int)}.
- */
- public static final int PUBLISH_TYPE_SOLICITED = 1;
-
- /**
- * @hide
- */
- public final int mPublishType;
-
- /**
- * @hide
- */
- public final int mPublishCount;
-
- /**
- * @hide
- */
- public final int mTtlSec;
-
- private PublishSettings(int publishType, int publichCount, int ttlSec) {
- mPublishType = publishType;
- mPublishCount = publichCount;
- mTtlSec = ttlSec;
- }
-
- @Override
- public String toString() {
- return "PublishSettings [mPublishType=" + mPublishType + ", mPublishCount=" + mPublishCount
- + ", mTtlSec=" + mTtlSec + "]";
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mPublishType);
- dest.writeInt(mPublishCount);
- dest.writeInt(mTtlSec);
- }
-
- public static final Creator<PublishSettings> CREATOR = new Creator<PublishSettings>() {
- @Override
- public PublishSettings[] newArray(int size) {
- return new PublishSettings[size];
- }
-
- @Override
- public PublishSettings createFromParcel(Parcel in) {
- int publishType = in.readInt();
- int publishCount = in.readInt();
- int ttlSec = in.readInt();
- return new PublishSettings(publishType, publishCount, ttlSec);
- }
- };
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (!(o instanceof PublishSettings)) {
- return false;
- }
-
- PublishSettings lhs = (PublishSettings) o;
-
- return mPublishType == lhs.mPublishType && mPublishCount == lhs.mPublishCount
- && mTtlSec == lhs.mTtlSec;
- }
-
- @Override
- public int hashCode() {
- int result = 17;
-
- result = 31 * result + mPublishType;
- result = 31 * result + mPublishCount;
- result = 31 * result + mTtlSec;
-
- return result;
- }
-
- /**
- * Builder used to build {@link PublishSettings} objects.
- */
- public static final class Builder {
- int mPublishType;
- int mPublishCount;
- int mTtlSec;
-
- /**
- * Sets the type of the publish session: solicited (aka active - publish
- * packets are transmitted over-the-air), or unsolicited (aka passive -
- * no publish packets are transmitted, a match is made against an active
- * subscribe session whose packets are transmitted over-the-air).
- *
- * @param publishType Publish session type: solicited (
- * {@link PublishSettings#PUBLISH_TYPE_SOLICITED}) or
- * unsolicited (
- * {@link PublishSettings#PUBLISH_TYPE_UNSOLICITED}).
- * @return The builder to facilitate chaining
- * {@code builder.setXXX(..).setXXX(..)}.
- */
- public Builder setPublishType(int publishType) {
- if (publishType < PUBLISH_TYPE_UNSOLICITED || publishType > PUBLISH_TYPE_SOLICITED) {
- throw new IllegalArgumentException("Invalid publishType - " + publishType);
- }
- mPublishType = publishType;
- return this;
- }
-
- /**
- * Sets the number of times a solicited (
- * {@link PublishSettings.Builder#setPublishType(int)}) publish session
- * will transmit a packet. When the count is reached an event will be
- * generated for {@link WifiNanSessionListener#onPublishTerminated(int)}
- * with reason={@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
- *
- * @param publishCount Number of publish packets to transmit.
- * @return The builder to facilitate chaining
- * {@code builder.setXXX(..).setXXX(..)}.
- */
- public Builder setPublishCount(int publishCount) {
- if (publishCount < 0) {
- throw new IllegalArgumentException("Invalid publishCount - must be non-negative");
- }
- mPublishCount = publishCount;
- return this;
- }
-
- /**
- * Sets the time interval (in seconds) a solicited (
- * {@link PublishSettings.Builder#setPublishCount(int)}) publish session
- * will be alive - i.e. transmitting a packet. When the TTL is reached
- * an event will be generated for
- * {@link WifiNanSessionListener#onPublishTerminated(int)} with reason=
- * {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
- *
- * @param ttlSec Lifetime of a publish session in seconds.
- * @return The builder to facilitate chaining
- * {@code builder.setXXX(..).setXXX(..)}.
- */
- public Builder setTtlSec(int ttlSec) {
- if (ttlSec < 0) {
- throw new IllegalArgumentException("Invalid ttlSec - must be non-negative");
- }
- mTtlSec = ttlSec;
- return this;
- }
-
- /**
- * Build {@link PublishSettings} given the current requests made on the
- * builder.
- */
- public PublishSettings build() {
- return new PublishSettings(mPublishType, mPublishCount, mTtlSec);
- }
- }
-}
diff --git a/wifi/java/android/net/wifi/nan/SubscribeSettings.aidl b/wifi/java/android/net/wifi/nan/SubscribeConfig.aidl
similarity index 95%
rename from wifi/java/android/net/wifi/nan/SubscribeSettings.aidl
rename to wifi/java/android/net/wifi/nan/SubscribeConfig.aidl
index 44849bc..92344a4 100644
--- a/wifi/java/android/net/wifi/nan/SubscribeSettings.aidl
+++ b/wifi/java/android/net/wifi/nan/SubscribeConfig.aidl
@@ -16,4 +16,4 @@
package android.net.wifi.nan;
-parcelable SubscribeSettings;
+parcelable SubscribeConfig;
diff --git a/wifi/java/android/net/wifi/nan/SubscribeData.java b/wifi/java/android/net/wifi/nan/SubscribeConfig.java
similarity index 60%
rename from wifi/java/android/net/wifi/nan/SubscribeData.java
rename to wifi/java/android/net/wifi/nan/SubscribeConfig.java
index cd6e918..4798293 100644
--- a/wifi/java/android/net/wifi/nan/SubscribeData.java
+++ b/wifi/java/android/net/wifi/nan/SubscribeConfig.java
@@ -22,14 +22,30 @@
import java.util.Arrays;
/**
- * Defines the data for a NAN subscribe session. Built using
- * {@link SubscribeData.Builder}. Subscribe is done using
- * {@link WifiNanManager#subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)}
- * or
- * {@link WifiNanSubscribeSession#subscribe(SubscribeData, SubscribeSettings)}.
+ * Defines the configuration of a NAN subscribe session. Built using
+ * {@link SubscribeConfig.Builder}. Subscribe is done using
+ * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionListener, int)}
+ * or {@link WifiNanSubscribeSession#subscribe(SubscribeConfig)}.
+ *
* @hide PROPOSED_NAN_API
*/
-public class SubscribeData implements Parcelable {
+public class SubscribeConfig implements Parcelable {
+
+ /**
+ * Defines a passive subscribe session - i.e. a subscribe session where
+ * subscribe packets are not transmitted over-the-air and the device listens
+ * and matches to transmitted publish packets. Configuration is done using
+ * {@link SubscribeConfig.Builder#setSubscribeType(int)}.
+ */
+ public static final int SUBSCRIBE_TYPE_PASSIVE = 0;
+
+ /**
+ * Defines an active subscribe session - i.e. a subscribe session where
+ * subscribe packets are transmitted over-the-air. Configuration is done
+ * using {@link SubscribeConfig.Builder#setSubscribeType(int)}.
+ */
+ public static final int SUBSCRIBE_TYPE_ACTIVE = 1;
+
/**
* @hide
*/
@@ -65,9 +81,24 @@
*/
public final byte[] mRxFilter;
- private SubscribeData(String serviceName, byte[] serviceSpecificInfo,
+ /**
+ * @hide
+ */
+ public final int mSubscribeType;
+
+ /**
+ * @hide
+ */
+ public final int mSubscribeCount;
+
+ /**
+ * @hide
+ */
+ public final int mTtlSec;
+
+ private SubscribeConfig(String serviceName, byte[] serviceSpecificInfo,
int serviceSpecificInfoLength, byte[] txFilter, int txFilterLength, byte[] rxFilter,
- int rxFilterLength) {
+ int rxFilterLength, int subscribeType, int publichCount, int ttlSec) {
mServiceName = serviceName;
mServiceSpecificInfoLength = serviceSpecificInfoLength;
mServiceSpecificInfo = serviceSpecificInfo;
@@ -75,17 +106,21 @@
mTxFilter = txFilter;
mRxFilterLength = rxFilterLength;
mRxFilter = rxFilter;
+ mSubscribeType = subscribeType;
+ mSubscribeCount = publichCount;
+ mTtlSec = ttlSec;
}
@Override
public String toString() {
- return "SubscribeData [mServiceName='" + mServiceName + "', mServiceSpecificInfo='"
+ return "SubscribeConfig [mServiceName='" + mServiceName + "', mServiceSpecificInfo='"
+ (new String(mServiceSpecificInfo, 0, mServiceSpecificInfoLength))
+ "', mTxFilter="
+ (new TlvBufferUtils.TlvIterable(0, 1, mTxFilter, mTxFilterLength)).toString()
+ ", mRxFilter="
+ (new TlvBufferUtils.TlvIterable(0, 1, mRxFilter, mRxFilterLength)).toString()
- + "']";
+ + ", mSubscribeType=" + mSubscribeType + ", mSubscribeCount=" + mSubscribeCount
+ + ", mTtlSec=" + mTtlSec + "']";
}
@Override
@@ -108,16 +143,19 @@
if (mRxFilterLength != 0) {
dest.writeByteArray(mRxFilter, 0, mRxFilterLength);
}
+ dest.writeInt(mSubscribeType);
+ dest.writeInt(mSubscribeCount);
+ dest.writeInt(mTtlSec);
}
- public static final Creator<SubscribeData> CREATOR = new Creator<SubscribeData>() {
+ public static final Creator<SubscribeConfig> CREATOR = new Creator<SubscribeConfig>() {
@Override
- public SubscribeData[] newArray(int size) {
- return new SubscribeData[size];
+ public SubscribeConfig[] newArray(int size) {
+ return new SubscribeConfig[size];
}
@Override
- public SubscribeData createFromParcel(Parcel in) {
+ public SubscribeConfig createFromParcel(Parcel in) {
String serviceName = in.readString();
int ssiLength = in.readInt();
byte[] ssi = new byte[ssiLength];
@@ -134,9 +172,11 @@
if (rxFilterLength != 0) {
in.readByteArray(rxFilter);
}
-
- return new SubscribeData(serviceName, ssi, ssiLength, txFilter, txFilterLength,
- rxFilter, rxFilterLength);
+ int subscribeType = in.readInt();
+ int subscribeCount = in.readInt();
+ int ttlSec = in.readInt();
+ return new SubscribeConfig(serviceName, ssi, ssiLength, txFilter, txFilterLength,
+ rxFilter, rxFilterLength, subscribeType, subscribeCount, ttlSec);
}
};
@@ -146,11 +186,11 @@
return true;
}
- if (!(o instanceof SubscribeData)) {
+ if (!(o instanceof SubscribeConfig)) {
return false;
}
- SubscribeData lhs = (SubscribeData) o;
+ SubscribeConfig lhs = (SubscribeConfig) o;
if (!mServiceName.equals(lhs.mServiceName)
|| mServiceSpecificInfoLength != lhs.mServiceSpecificInfoLength
@@ -189,7 +229,8 @@
return false; // invalid != invalid
}
- return true;
+ return mSubscribeType == lhs.mSubscribeType && mSubscribeCount == lhs.mSubscribeCount
+ && mTtlSec == lhs.mTtlSec;
}
@Override
@@ -203,12 +244,15 @@
result = 31 * result + Arrays.hashCode(mTxFilter);
result = 31 * result + mRxFilterLength;
result = 31 * result + Arrays.hashCode(mRxFilter);
+ result = 31 * result + mSubscribeType;
+ result = 31 * result + mSubscribeCount;
+ result = 31 * result + mTtlSec;
return result;
}
/**
- * Builder used to build {@link SubscribeData} objects.
+ * Builder used to build {@link SubscribeConfig} objects.
*/
public static final class Builder {
private String mServiceName;
@@ -218,6 +262,9 @@
private byte[] mTxFilter = new byte[0];
private int mRxFilterLength;
private byte[] mRxFilter = new byte[0];
+ private int mSubscribeType;
+ private int mSubscribeCount;
+ private int mTtlSec;
/**
* Specify the service name of the subscribe session. The actual on-air
@@ -255,7 +302,8 @@
/**
* Specify service specific information for the subscribe session - same
- * as {@link SubscribeData.Builder#setServiceSpecificInfo(byte[], int)}
+ * as
+ * {@link SubscribeConfig.Builder#setServiceSpecificInfo(byte[], int)}
* but obtaining the data from a String.
*
* @param serviceSpecificInfoStr The service specific information string
@@ -272,8 +320,8 @@
/**
* The transmit filter for an active subscribe session
- * {@link SubscribeSettings.Builder#setSubscribeType(int)} and
- * {@link SubscribeSettings#SUBSCRIBE_TYPE_ACTIVE}. Included in
+ * {@link SubscribeConfig.Builder#setSubscribeType(int)} and
+ * {@link SubscribeConfig#SUBSCRIBE_TYPE_ACTIVE}. Included in
* transmitted subscribe packets and used by receivers (passive
* publishers) to determine whether they match - in addition to just
* relying on the service name.
@@ -296,8 +344,8 @@
/**
* The transmit filter for a passive subsribe session
- * {@link SubscribeSettings.Builder#setSubscribeType(int)} and
- * {@link SubscribeSettings#SUBSCRIBE_TYPE_PASSIVE}. Used by the
+ * {@link SubscribeConfig.Builder#setSubscribeType(int)} and
+ * {@link SubscribeConfig#SUBSCRIBE_TYPE_PASSIVE}. Used by the
* subscriber to determine whether they match transmitted publish
* packets - in addition to just relying on the service name.
* <p>
@@ -318,12 +366,73 @@
}
/**
- * Build {@link SubscribeData} given the current requests made on the
+ * Sets the type of the subscribe session: active (subscribe packets are
+ * transmitted over-the-air), or passive (no subscribe packets are
+ * transmitted, a match is made against a solicited/active publish
+ * session whose packets are transmitted over-the-air).
+ *
+ * @param subscribeType Subscribe session type: active (
+ * {@link SubscribeConfig#SUBSCRIBE_TYPE_ACTIVE}) or passive
+ * ( {@link SubscribeConfig#SUBSCRIBE_TYPE_PASSIVE} ).
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setSubscribeType(int subscribeType) {
+ if (subscribeType < SUBSCRIBE_TYPE_PASSIVE || subscribeType > SUBSCRIBE_TYPE_ACTIVE) {
+ throw new IllegalArgumentException("Invalid subscribeType - " + subscribeType);
+ }
+ mSubscribeType = subscribeType;
+ return this;
+ }
+
+ /**
+ * Sets the number of times an active (
+ * {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe
+ * session will transmit a packet. When the count is reached an event
+ * will be generated for
+ * {@link WifiNanSessionListener#onSubscribeTerminated(int)} with
+ * reason= {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
+ *
+ * @param subscribeCount Number of subscribe packets to transmit.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setSubscribeCount(int subscribeCount) {
+ if (subscribeCount < 0) {
+ throw new IllegalArgumentException("Invalid subscribeCount - must be non-negative");
+ }
+ mSubscribeCount = subscribeCount;
+ return this;
+ }
+
+ /**
+ * Sets the time interval (in seconds) an active (
+ * {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe
+ * session will be alive - i.e. transmitting a packet. When the TTL is
+ * reached an event will be generated for
+ * {@link WifiNanSessionListener#onSubscribeTerminated(int)} with
+ * reason= {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
+ *
+ * @param ttlSec Lifetime of a subscribe session in seconds.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setTtlSec(int ttlSec) {
+ if (ttlSec < 0) {
+ throw new IllegalArgumentException("Invalid ttlSec - must be non-negative");
+ }
+ mTtlSec = ttlSec;
+ return this;
+ }
+
+ /**
+ * Build {@link SubscribeConfig} given the current requests made on the
* builder.
*/
- public SubscribeData build() {
- return new SubscribeData(mServiceName, mServiceSpecificInfo, mServiceSpecificInfoLength,
- mTxFilter, mTxFilterLength, mRxFilter, mRxFilterLength);
+ public SubscribeConfig build() {
+ return new SubscribeConfig(mServiceName, mServiceSpecificInfo,
+ mServiceSpecificInfoLength, mTxFilter, mTxFilterLength, mRxFilter,
+ mRxFilterLength, mSubscribeType, mSubscribeCount, mTtlSec);
}
}
}
diff --git a/wifi/java/android/net/wifi/nan/SubscribeData.aidl b/wifi/java/android/net/wifi/nan/SubscribeData.aidl
deleted file mode 100644
index 662fdb8..0000000
--- a/wifi/java/android/net/wifi/nan/SubscribeData.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.nan;
-
-parcelable SubscribeData;
diff --git a/wifi/java/android/net/wifi/nan/SubscribeSettings.java b/wifi/java/android/net/wifi/nan/SubscribeSettings.java
deleted file mode 100644
index 5c4f8fb..0000000
--- a/wifi/java/android/net/wifi/nan/SubscribeSettings.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.nan;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Defines the settings (configuration) for a NAN subscribe session. Built using
- * {@link SubscribeSettings.Builder}. Subscribe is done using
- * {@link WifiNanManager#subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)}
- * or {@link WifiNanSubscribeSession#subscribe(SubscribeData, SubscribeSettings)}.
- *
- * @hide PROPOSED_NAN_API
- */
-public class SubscribeSettings implements Parcelable {
-
- /**
- * Defines a passive subscribe session - i.e. a subscribe session where
- * subscribe packets are not transmitted over-the-air and the device listens
- * and matches to transmitted publish packets. Configuration is done using
- * {@link SubscribeSettings.Builder#setSubscribeType(int)}.
- */
- public static final int SUBSCRIBE_TYPE_PASSIVE = 0;
-
- /**
- * Defines an active subscribe session - i.e. a subscribe session where
- * subscribe packets are transmitted over-the-air. Configuration is done
- * using {@link SubscribeSettings.Builder#setSubscribeType(int)}.
- */
- public static final int SUBSCRIBE_TYPE_ACTIVE = 1;
-
- /**
- * @hide
- */
- public final int mSubscribeType;
-
- /**
- * @hide
- */
- public final int mSubscribeCount;
-
- /**
- * @hide
- */
- public final int mTtlSec;
-
- private SubscribeSettings(int subscribeType, int publichCount, int ttlSec) {
- mSubscribeType = subscribeType;
- mSubscribeCount = publichCount;
- mTtlSec = ttlSec;
- }
-
- @Override
- public String toString() {
- return "SubscribeSettings [mSubscribeType=" + mSubscribeType + ", mSubscribeCount="
- + mSubscribeCount + ", mTtlSec=" + mTtlSec + "]";
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mSubscribeType);
- dest.writeInt(mSubscribeCount);
- dest.writeInt(mTtlSec);
- }
-
- public static final Creator<SubscribeSettings> CREATOR = new Creator<SubscribeSettings>() {
- @Override
- public SubscribeSettings[] newArray(int size) {
- return new SubscribeSettings[size];
- }
-
- @Override
- public SubscribeSettings createFromParcel(Parcel in) {
- int subscribeType = in.readInt();
- int subscribeCount = in.readInt();
- int ttlSec = in.readInt();
- return new SubscribeSettings(subscribeType, subscribeCount, ttlSec);
- }
- };
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (!(o instanceof SubscribeSettings)) {
- return false;
- }
-
- SubscribeSettings lhs = (SubscribeSettings) o;
-
- return mSubscribeType == lhs.mSubscribeType && mSubscribeCount == lhs.mSubscribeCount
- && mTtlSec == lhs.mTtlSec;
- }
-
- @Override
- public int hashCode() {
- int result = 17;
-
- result = 31 * result + mSubscribeType;
- result = 31 * result + mSubscribeCount;
- result = 31 * result + mTtlSec;
-
- return result;
- }
-
- /**
- * Builder used to build {@link SubscribeSettings} objects.
- */
- public static final class Builder {
- int mSubscribeType;
- int mSubscribeCount;
- int mTtlSec;
-
- /**
- * Sets the type of the subscribe session: active (subscribe packets are
- * transmitted over-the-air), or passive (no subscribe packets are
- * transmitted, a match is made against a solicited/active publish
- * session whose packets are transmitted over-the-air).
- *
- * @param subscribeType Subscribe session type: active (
- * {@link SubscribeSettings#SUBSCRIBE_TYPE_ACTIVE}) or
- * passive ( {@link SubscribeSettings#SUBSCRIBE_TYPE_PASSIVE}
- * ).
- * @return The builder to facilitate chaining
- * {@code builder.setXXX(..).setXXX(..)}.
- */
- public Builder setSubscribeType(int subscribeType) {
- if (subscribeType < SUBSCRIBE_TYPE_PASSIVE || subscribeType > SUBSCRIBE_TYPE_ACTIVE) {
- throw new IllegalArgumentException("Invalid subscribeType - " + subscribeType);
- }
- mSubscribeType = subscribeType;
- return this;
- }
-
- /**
- * Sets the number of times an active (
- * {@link SubscribeSettings.Builder#setSubscribeType(int)}) subscribe
- * session will transmit a packet. When the count is reached an event
- * will be generated for
- * {@link WifiNanSessionListener#onSubscribeTerminated(int)} with reason=
- * {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
- *
- * @param subscribeCount Number of subscribe packets to transmit.
- * @return The builder to facilitate chaining
- * {@code builder.setXXX(..).setXXX(..)}.
- */
- public Builder setSubscribeCount(int subscribeCount) {
- if (subscribeCount < 0) {
- throw new IllegalArgumentException("Invalid subscribeCount - must be non-negative");
- }
- mSubscribeCount = subscribeCount;
- return this;
- }
-
- /**
- * Sets the time interval (in seconds) an active (
- * {@link SubscribeSettings.Builder#setSubscribeType(int)}) subscribe
- * session will be alive - i.e. transmitting a packet. When the TTL is
- * reached an event will be generated for
- * {@link WifiNanSessionListener#onSubscribeTerminated(int)} with reason=
- * {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
- *
- * @param ttlSec Lifetime of a subscribe session in seconds.
- * @return The builder to facilitate chaining
- * {@code builder.setXXX(..).setXXX(..)}.
- */
- public Builder setTtlSec(int ttlSec) {
- if (ttlSec < 0) {
- throw new IllegalArgumentException("Invalid ttlSec - must be non-negative");
- }
- mTtlSec = ttlSec;
- return this;
- }
-
- /**
- * Build {@link SubscribeSettings} given the current requests made on
- * the builder.
- */
- public SubscribeSettings build() {
- return new SubscribeSettings(mSubscribeType, mSubscribeCount, mTtlSec);
- }
- }
-}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanManager.java b/wifi/java/android/net/wifi/nan/WifiNanManager.java
index 721c828..fa9d128 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanManager.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanManager.java
@@ -130,21 +130,19 @@
* operation will result in callbacks to the indicated listener:
* {@link WifiNanSessionListener NanSessionListener.on*}.
*
- * @param publishData The {@link PublishData} specifying the contents of the
- * publish session.
- * @param publishSettings The {@link PublishSettings} specifying the
- * settings for the publish session.
- * @param listener The {@link WifiNanSessionListener} derived objects to be used
- * for the event callbacks specified by {@code events}.
+ * @param publishConfig The {@link PublishConfig} specifying the
+ * configuration of the publish session.
+ * @param listener The {@link WifiNanSessionListener} derived objects to be
+ * used for the event callbacks specified by {@code events}.
* @param events The list of events to be delivered to the {@code listener}
* object. An OR'd value of {@link WifiNanSessionListener
* NanSessionListener.LISTEN_*}.
* @return The {@link WifiNanPublishSession} which can be used to further
* control the publish session.
*/
- public WifiNanPublishSession publish(PublishData publishData, PublishSettings publishSettings,
+ public WifiNanPublishSession publish(PublishConfig publishConfig,
WifiNanSessionListener listener, int events) {
- return publishRaw(publishData, publishSettings, listener,
+ return publishRaw(publishConfig, listener,
events | WifiNanSessionListener.LISTEN_HIDDEN_FLAGS);
}
@@ -153,18 +151,18 @@
*
* @hide
*/
- public WifiNanPublishSession publishRaw(PublishData publishData,
- PublishSettings publishSettings, WifiNanSessionListener listener, int events) {
- if (VDBG) Log.v(TAG, "publish(): data='" + publishData + "', settings=" + publishSettings);
+ public WifiNanPublishSession publishRaw(PublishConfig publishConfig,
+ WifiNanSessionListener listener, int events) {
+ if (VDBG) Log.v(TAG, "publish(): config=" + publishConfig);
- if (publishSettings.mPublishType == PublishSettings.PUBLISH_TYPE_UNSOLICITED
- && publishData.mRxFilterLength != 0) {
- throw new IllegalArgumentException("Invalid publish data & settings: UNSOLICITED "
+ if (publishConfig.mPublishType == PublishConfig.PUBLISH_TYPE_UNSOLICITED
+ && publishConfig.mRxFilterLength != 0) {
+ throw new IllegalArgumentException("Invalid publish config: UNSOLICITED "
+ "publishes (active) can't have an Rx filter");
}
- if (publishSettings.mPublishType == PublishSettings.PUBLISH_TYPE_SOLICITED
- && publishData.mTxFilterLength != 0) {
- throw new IllegalArgumentException("Invalid publish data & settings: SOLICITED "
+ if (publishConfig.mPublishType == PublishConfig.PUBLISH_TYPE_SOLICITED
+ && publishConfig.mTxFilterLength != 0) {
+ throw new IllegalArgumentException("Invalid publish config: SOLICITED "
+ "publishes (passive) can't have a Tx filter");
}
if (listener == null) {
@@ -176,7 +174,7 @@
try {
sessionId = mService.createSession(mClientId, listener.callback, events);
if (DBG) Log.d(TAG, "publish: session created - sessionId=" + sessionId);
- mService.publish(mClientId, sessionId, publishData, publishSettings);
+ mService.publish(mClientId, sessionId, publishConfig);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -187,47 +185,45 @@
/**
* {@hide}
*/
- public void publish(int sessionId, PublishData publishData, PublishSettings publishSettings) {
- if (VDBG) Log.v(TAG, "publish(): data='" + publishData + "', settings=" + publishSettings);
+ public void publish(int sessionId, PublishConfig publishConfig) {
+ if (VDBG) Log.v(TAG, "publish(): config=" + publishConfig);
- if (publishSettings.mPublishType == PublishSettings.PUBLISH_TYPE_UNSOLICITED
- && publishData.mRxFilterLength != 0) {
- throw new IllegalArgumentException("Invalid publish data & settings: UNSOLICITED "
+ if (publishConfig.mPublishType == PublishConfig.PUBLISH_TYPE_UNSOLICITED
+ && publishConfig.mRxFilterLength != 0) {
+ throw new IllegalArgumentException("Invalid publish config: UNSOLICITED "
+ "publishes (active) can't have an Rx filter");
}
- if (publishSettings.mPublishType == PublishSettings.PUBLISH_TYPE_SOLICITED
- && publishData.mTxFilterLength != 0) {
- throw new IllegalArgumentException("Invalid publish data & settings: SOLICITED "
+ if (publishConfig.mPublishType == PublishConfig.PUBLISH_TYPE_SOLICITED
+ && publishConfig.mTxFilterLength != 0) {
+ throw new IllegalArgumentException("Invalid publish config: SOLICITED "
+ "publishes (passive) can't have a Tx filter");
}
try {
- mService.publish(mClientId, sessionId, publishData, publishSettings);
+ mService.publish(mClientId, sessionId, publishConfig);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
+
/**
* Request a NAN subscribe session. The results of the subscribe session
* operation will result in callbacks to the indicated listener:
* {@link WifiNanSessionListener NanSessionListener.on*}.
*
- * @param subscribeData The {@link SubscribeData} specifying the contents of
- * the subscribe session.
- * @param subscribeSettings The {@link SubscribeSettings} specifying the
- * settings for the subscribe session.
- * @param listener The {@link WifiNanSessionListener} derived objects to be used
- * for the event callbacks specified by {@code events}.
+ * @param subscribeConfig The {@link SubscribeConfig} specifying the
+ * configuration of the subscribe session.
+ * @param listener The {@link WifiNanSessionListener} derived objects to be
+ * used for the event callbacks specified by {@code events}.
* @param events The list of events to be delivered to the {@code listener}
* object. An OR'd value of {@link WifiNanSessionListener
* NanSessionListener.LISTEN_*}.
* @return The {@link WifiNanSubscribeSession} which can be used to further
* control the subscribe session.
*/
- public WifiNanSubscribeSession subscribe(SubscribeData subscribeData,
- SubscribeSettings subscribeSettings,
+ public WifiNanSubscribeSession subscribe(SubscribeConfig subscribeConfig,
WifiNanSessionListener listener, int events) {
- return subscribeRaw(subscribeData, subscribeSettings, listener,
+ return subscribeRaw(subscribeConfig, listener,
events | WifiNanSessionListener.LISTEN_HIDDEN_FLAGS);
}
@@ -236,21 +232,21 @@
*
* @hide
*/
- public WifiNanSubscribeSession subscribeRaw(SubscribeData subscribeData,
- SubscribeSettings subscribeSettings, WifiNanSessionListener listener, int events) {
+ public WifiNanSubscribeSession subscribeRaw(SubscribeConfig subscribeConfig,
+ WifiNanSessionListener listener, int events) {
if (VDBG) {
- Log.v(TAG, "subscribe(): data='" + subscribeData + "', settings=" + subscribeSettings);
+ Log.v(TAG, "subscribe(): config=" + subscribeConfig);
}
- if (subscribeSettings.mSubscribeType == SubscribeSettings.SUBSCRIBE_TYPE_ACTIVE
- && subscribeData.mRxFilterLength != 0) {
+ if (subscribeConfig.mSubscribeType == SubscribeConfig.SUBSCRIBE_TYPE_ACTIVE
+ && subscribeConfig.mRxFilterLength != 0) {
throw new IllegalArgumentException(
- "Invalid subscribe data & settings: ACTIVE subscribes can't have an Rx filter");
+ "Invalid subscribe config: ACTIVE subscribes can't have an Rx filter");
}
- if (subscribeSettings.mSubscribeType == SubscribeSettings.SUBSCRIBE_TYPE_PASSIVE
- && subscribeData.mTxFilterLength != 0) {
+ if (subscribeConfig.mSubscribeType == SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE
+ && subscribeConfig.mTxFilterLength != 0) {
throw new IllegalArgumentException(
- "Invalid subscribe data & settings: PASSIVE subscribes can't have a Tx filter");
+ "Invalid subscribe config: PASSIVE subscribes can't have a Tx filter");
}
int sessionId;
@@ -258,7 +254,7 @@
try {
sessionId = mService.createSession(mClientId, listener.callback, events);
if (DBG) Log.d(TAG, "subscribe: session created - sessionId=" + sessionId);
- mService.subscribe(mClientId, sessionId, subscribeData, subscribeSettings);
+ mService.subscribe(mClientId, sessionId, subscribeConfig);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -269,25 +265,24 @@
/**
* {@hide}
*/
- public void subscribe(int sessionId, SubscribeData subscribeData,
- SubscribeSettings subscribeSettings) {
+ public void subscribe(int sessionId, SubscribeConfig subscribeConfig) {
if (VDBG) {
- Log.v(TAG, "subscribe(): data='" + subscribeData + "', settings=" + subscribeSettings);
+ Log.v(TAG, "subscribe(): config=" + subscribeConfig);
}
- if (subscribeSettings.mSubscribeType == SubscribeSettings.SUBSCRIBE_TYPE_ACTIVE
- && subscribeData.mRxFilterLength != 0) {
+ if (subscribeConfig.mSubscribeType == SubscribeConfig.SUBSCRIBE_TYPE_ACTIVE
+ && subscribeConfig.mRxFilterLength != 0) {
throw new IllegalArgumentException(
- "Invalid subscribe data & settings: ACTIVE subscribes can't have an Rx filter");
+ "Invalid subscribe config: ACTIVE subscribes can't have an Rx filter");
}
- if (subscribeSettings.mSubscribeType == SubscribeSettings.SUBSCRIBE_TYPE_PASSIVE
- && subscribeData.mTxFilterLength != 0) {
+ if (subscribeConfig.mSubscribeType == SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE
+ && subscribeConfig.mTxFilterLength != 0) {
throw new IllegalArgumentException(
- "Invalid subscribe data & settings: PASSIVE subscribes can't have a Tx filter");
+ "Invalid subscribe config: PASSIVE subscribes can't have a Tx filter");
}
try {
- mService.subscribe(mClientId, sessionId, subscribeData, subscribeSettings);
+ mService.subscribe(mClientId, sessionId, subscribeConfig);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanPublishSession.java b/wifi/java/android/net/wifi/nan/WifiNanPublishSession.java
index 81b38f4..eae9c65 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanPublishSession.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanPublishSession.java
@@ -18,8 +18,8 @@
/**
* A representation of a NAN publish session. Created when
- * {@link WifiNanManager#publish(PublishData, PublishSettings, WifiNanSessionListener, int)}
- * is executed. The object can be used to stop and re-start (re-configure) the
+ * {@link WifiNanManager#publish(PublishConfig, WifiNanSessionListener, int)} is
+ * executed. The object can be used to stop and re-start (re-configure) the
* publish session.
*
* @hide PROPOSED_NAN_API
@@ -34,14 +34,13 @@
/**
* Restart/re-configure the publish session. Note that the
- * {@link WifiNanSessionListener} is not replaced - the same listener used at
- * creation is still used.
+ * {@link WifiNanSessionListener} is not replaced - the same listener used
+ * at creation is still used.
*
- * @param publishData The data ({@link PublishData}) to publish.
- * @param publishSettings The settings ({@link PublishSettings}) of the
+ * @param publishConfig The configuration ({@link PublishConfig}) of the
* publish session.
*/
- public void publish(PublishData publishData, PublishSettings publishSettings) {
- mManager.publish(mSessionId, publishData, publishSettings);
+ public void publish(PublishConfig publishConfig) {
+ mManager.publish(mSessionId, publishConfig);
}
}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanSessionListener.java b/wifi/java/android/net/wifi/nan/WifiNanSessionListener.java
index b9af7def..4cc9cf5 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanSessionListener.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanSessionListener.java
@@ -26,11 +26,11 @@
* Base class for NAN session events callbacks. Should be extended by
* applications wanting notifications. The callbacks are registered when a
* publish or subscribe session is created using
- * {@link WifiNanManager#publish(PublishData, PublishSettings, WifiNanSessionListener, int)}
- * or
- * {@link WifiNanManager#subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)}
+ * {@link WifiNanManager#publish(PublishConfig, WifiNanSessionListener, int)} or
+ * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionListener, int)}
* . These are callbacks applying to a specific NAN session. Events
- * corresponding to the NAN link are delivered using {@link WifiNanEventListener}.
+ * corresponding to the NAN link are delivered using
+ * {@link WifiNanEventListener}.
* <p>
* A single listener is registered at session creation - it cannot be replaced.
* <p>
@@ -150,8 +150,8 @@
* {@link WifiNanSessionListener#onPublishTerminated(int)} and
* {@link WifiNanSessionListener#onSubscribeTerminated(int)} callbacks.
* Indicates that publish or subscribe session is done - i.e. all the
- * requested operations (per {@link PublishSettings} or
- * {@link SubscribeSettings}) have been executed.
+ * requested operations (per {@link PublishConfig} or
+ * {@link SubscribeConfig}) have been executed.
*/
public static final int TERMINATE_REASON_DONE = 0;
diff --git a/wifi/java/android/net/wifi/nan/WifiNanSubscribeSession.java b/wifi/java/android/net/wifi/nan/WifiNanSubscribeSession.java
index 7dfdd32..d2f13c8 100644
--- a/wifi/java/android/net/wifi/nan/WifiNanSubscribeSession.java
+++ b/wifi/java/android/net/wifi/nan/WifiNanSubscribeSession.java
@@ -18,7 +18,7 @@
/**
* A representation of a NAN subscribe session. Created when
- * {@link WifiNanManager#subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)}
+ * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionListener, int)}
* is executed. The object can be used to stop and re-start (re-configure) the
* subscribe session.
*
@@ -34,14 +34,13 @@
/**
* Restart/re-configure the subscribe session. Note that the
- * {@link WifiNanSessionListener} is not replaced - the same listener used at
- * creation is still used.
+ * {@link WifiNanSessionListener} is not replaced - the same listener used
+ * at creation is still used.
*
- * @param subscribeData The data ({@link SubscribeData}) to subscribe.
- * @param subscribeSettings The settings ({@link SubscribeSettings}) of the
+ * @param subscribeConfig The configuration ({@link SubscribeConfig}) of the
* subscribe session.
*/
- public void subscribe(SubscribeData subscribeData, SubscribeSettings subscribeSettings) {
- mManager.subscribe(mSessionId, subscribeData, subscribeSettings);
+ public void subscribe(SubscribeConfig subscribeConfig) {
+ mManager.subscribe(mSessionId, subscribeConfig);
}
}