Merge "[AWARE] Remove match style API" into oc-dev
This commit is contained in:
@@ -26795,8 +26795,6 @@ package android.net.wifi.aware {
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.net.wifi.aware.SubscribeConfig> CREATOR;
|
||||
field public static final int MATCH_STYLE_ALL = 1; // 0x1
|
||||
field public static final int MATCH_STYLE_FIRST_ONLY = 0; // 0x0
|
||||
field public static final int SUBSCRIBE_TYPE_ACTIVE = 1; // 0x1
|
||||
field public static final int SUBSCRIBE_TYPE_PASSIVE = 0; // 0x0
|
||||
}
|
||||
@@ -26805,7 +26803,6 @@ package android.net.wifi.aware {
|
||||
ctor public SubscribeConfig.Builder();
|
||||
method public android.net.wifi.aware.SubscribeConfig build();
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setMatchFilter(java.util.List<byte[]>);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setMatchStyle(int);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setServiceName(java.lang.String);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setServiceSpecificInfo(byte[]);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setSubscribeType(int);
|
||||
|
||||
@@ -29540,8 +29540,6 @@ package android.net.wifi.aware {
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.net.wifi.aware.SubscribeConfig> CREATOR;
|
||||
field public static final int MATCH_STYLE_ALL = 1; // 0x1
|
||||
field public static final int MATCH_STYLE_FIRST_ONLY = 0; // 0x0
|
||||
field public static final int SUBSCRIBE_TYPE_ACTIVE = 1; // 0x1
|
||||
field public static final int SUBSCRIBE_TYPE_PASSIVE = 0; // 0x0
|
||||
}
|
||||
@@ -29550,7 +29548,6 @@ package android.net.wifi.aware {
|
||||
ctor public SubscribeConfig.Builder();
|
||||
method public android.net.wifi.aware.SubscribeConfig build();
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setMatchFilter(java.util.List<byte[]>);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setMatchStyle(int);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setServiceName(java.lang.String);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setServiceSpecificInfo(byte[]);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setSubscribeType(int);
|
||||
|
||||
@@ -26903,8 +26903,6 @@ package android.net.wifi.aware {
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.net.wifi.aware.SubscribeConfig> CREATOR;
|
||||
field public static final int MATCH_STYLE_ALL = 1; // 0x1
|
||||
field public static final int MATCH_STYLE_FIRST_ONLY = 0; // 0x0
|
||||
field public static final int SUBSCRIBE_TYPE_ACTIVE = 1; // 0x1
|
||||
field public static final int SUBSCRIBE_TYPE_PASSIVE = 0; // 0x0
|
||||
}
|
||||
@@ -26913,7 +26911,6 @@ package android.net.wifi.aware {
|
||||
ctor public SubscribeConfig.Builder();
|
||||
method public android.net.wifi.aware.SubscribeConfig build();
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setMatchFilter(java.util.List<byte[]>);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setMatchStyle(int);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setServiceName(java.lang.String);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setServiceSpecificInfo(byte[]);
|
||||
method public android.net.wifi.aware.SubscribeConfig.Builder setSubscribeType(int);
|
||||
|
||||
@@ -60,27 +60,6 @@ public final class SubscribeConfig implements Parcelable {
|
||||
*/
|
||||
public static final int SUBSCRIBE_TYPE_ACTIVE = 1;
|
||||
|
||||
/** @hide */
|
||||
@IntDef({
|
||||
MATCH_STYLE_FIRST_ONLY, MATCH_STYLE_ALL })
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface MatchStyles {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies that only the first match of a set of identical matches (same
|
||||
* publish) will be reported to the subscriber. Configuration is done using
|
||||
* {@link SubscribeConfig.Builder#setMatchStyle(int)}.
|
||||
*/
|
||||
public static final int MATCH_STYLE_FIRST_ONLY = 0;
|
||||
|
||||
/**
|
||||
* Specifies that all matches of a set of identical matches (same publish)
|
||||
* will be reported to the subscriber. Configuration is done using
|
||||
* {@link SubscribeConfig.Builder#setMatchStyle(int)}.
|
||||
*/
|
||||
public static final int MATCH_STYLE_ALL = 1;
|
||||
|
||||
/** @hide */
|
||||
public final byte[] mServiceName;
|
||||
|
||||
@@ -96,22 +75,18 @@ public final class SubscribeConfig implements Parcelable {
|
||||
/** @hide */
|
||||
public final int mTtlSec;
|
||||
|
||||
/** @hide */
|
||||
public final int mMatchStyle;
|
||||
|
||||
/** @hide */
|
||||
public final boolean mEnableTerminateNotification;
|
||||
|
||||
/** @hide */
|
||||
public SubscribeConfig(byte[] serviceName, byte[] serviceSpecificInfo, byte[] matchFilter,
|
||||
int subscribeType, int ttlSec, int matchStyle,
|
||||
int subscribeType, int ttlSec,
|
||||
boolean enableTerminateNotification) {
|
||||
mServiceName = serviceName;
|
||||
mServiceSpecificInfo = serviceSpecificInfo;
|
||||
mMatchFilter = matchFilter;
|
||||
mSubscribeType = subscribeType;
|
||||
mTtlSec = ttlSec;
|
||||
mMatchStyle = matchStyle;
|
||||
mEnableTerminateNotification = enableTerminateNotification;
|
||||
}
|
||||
|
||||
@@ -121,8 +96,8 @@ public final class SubscribeConfig implements Parcelable {
|
||||
(mServiceSpecificInfo == null) ? "null" : HexEncoding.encode(mServiceSpecificInfo))
|
||||
+ ", mMatchFilter=" + (new TlvBufferUtils.TlvIterable(0, 1,
|
||||
mMatchFilter)).toString() + ", mSubscribeType=" + mSubscribeType
|
||||
+ ", mTtlSec=" + mTtlSec + ", mMatchType="
|
||||
+ mMatchStyle + ", mEnableTerminateNotification=" + mEnableTerminateNotification
|
||||
+ ", mTtlSec=" + mTtlSec
|
||||
+ ", mEnableTerminateNotification=" + mEnableTerminateNotification
|
||||
+ "]";
|
||||
}
|
||||
|
||||
@@ -138,7 +113,6 @@ public final class SubscribeConfig implements Parcelable {
|
||||
dest.writeByteArray(mMatchFilter);
|
||||
dest.writeInt(mSubscribeType);
|
||||
dest.writeInt(mTtlSec);
|
||||
dest.writeInt(mMatchStyle);
|
||||
dest.writeInt(mEnableTerminateNotification ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -155,11 +129,10 @@ public final class SubscribeConfig implements Parcelable {
|
||||
byte[] matchFilter = in.createByteArray();
|
||||
int subscribeType = in.readInt();
|
||||
int ttlSec = in.readInt();
|
||||
int matchStyle = in.readInt();
|
||||
boolean enableTerminateNotification = in.readInt() != 0;
|
||||
|
||||
return new SubscribeConfig(serviceName, ssi, matchFilter, subscribeType,
|
||||
ttlSec, matchStyle, enableTerminateNotification);
|
||||
ttlSec, enableTerminateNotification);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -178,7 +151,7 @@ public final class SubscribeConfig implements Parcelable {
|
||||
return Arrays.equals(mServiceName, lhs.mServiceName) && Arrays.equals(mServiceSpecificInfo,
|
||||
lhs.mServiceSpecificInfo) && Arrays.equals(mMatchFilter, lhs.mMatchFilter)
|
||||
&& mSubscribeType == lhs.mSubscribeType
|
||||
&& mTtlSec == lhs.mTtlSec && mMatchStyle == lhs.mMatchStyle
|
||||
&& mTtlSec == lhs.mTtlSec
|
||||
&& mEnableTerminateNotification == lhs.mEnableTerminateNotification;
|
||||
}
|
||||
|
||||
@@ -191,7 +164,6 @@ public final class SubscribeConfig implements Parcelable {
|
||||
result = 31 * result + Arrays.hashCode(mMatchFilter);
|
||||
result = 31 * result + mSubscribeType;
|
||||
result = 31 * result + mTtlSec;
|
||||
result = 31 * result + mMatchStyle;
|
||||
result = 31 * result + (mEnableTerminateNotification ? 1 : 0);
|
||||
|
||||
return result;
|
||||
@@ -217,10 +189,6 @@ public final class SubscribeConfig implements Parcelable {
|
||||
if (mTtlSec < 0) {
|
||||
throw new IllegalArgumentException("Invalid ttlSec - must be non-negative");
|
||||
}
|
||||
if (mMatchStyle != MATCH_STYLE_FIRST_ONLY && mMatchStyle != MATCH_STYLE_ALL) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid matchType - must be MATCH_FIRST_ONLY or MATCH_ALL");
|
||||
}
|
||||
|
||||
if (characteristics != null) {
|
||||
int maxServiceNameLength = characteristics.getMaxServiceNameLength();
|
||||
@@ -252,7 +220,6 @@ public final class SubscribeConfig implements Parcelable {
|
||||
private byte[] mMatchFilter;
|
||||
private int mSubscribeType = SUBSCRIBE_TYPE_PASSIVE;
|
||||
private int mTtlSec = 0;
|
||||
private int mMatchStyle = MATCH_STYLE_ALL;
|
||||
private boolean mEnableTerminateNotification = true;
|
||||
|
||||
/**
|
||||
@@ -362,28 +329,6 @@ public final class SubscribeConfig implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the match style of the subscription - how are matches from a
|
||||
* single match session (corresponding to the same publish action on the
|
||||
* peer) reported to the host (using the
|
||||
* {@link DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[],
|
||||
* java.util.List)}). The options are: only report the first match and ignore the rest
|
||||
* {@link SubscribeConfig#MATCH_STYLE_FIRST_ONLY} or report every single
|
||||
* match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default).
|
||||
*
|
||||
* @param matchStyle The reporting style for the discovery match.
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setMatchStyle(@MatchStyles int matchStyle) {
|
||||
if (matchStyle != MATCH_STYLE_FIRST_ONLY && matchStyle != MATCH_STYLE_ALL) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid matchType - must be MATCH_FIRST_ONLY or MATCH_ALL");
|
||||
}
|
||||
mMatchStyle = matchStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure whether a subscribe terminate notification
|
||||
* {@link DiscoverySessionCallback#onSessionTerminated()} is reported
|
||||
@@ -406,7 +351,7 @@ public final class SubscribeConfig implements Parcelable {
|
||||
*/
|
||||
public SubscribeConfig build() {
|
||||
return new SubscribeConfig(mServiceName, mServiceSpecificInfo, mMatchFilter,
|
||||
mSubscribeType, mTtlSec, mMatchStyle,
|
||||
mSubscribeType, mTtlSec,
|
||||
mEnableTerminateNotification);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,8 +687,6 @@ public class WifiAwareManagerTest {
|
||||
collector.checkThat("mSubscribeType", subscribeConfig.mSubscribeType,
|
||||
equalTo(SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE));
|
||||
collector.checkThat("mTtlSec", subscribeConfig.mTtlSec, equalTo(0));
|
||||
collector.checkThat("mMatchStyle", subscribeConfig.mMatchStyle,
|
||||
equalTo(SubscribeConfig.MATCH_STYLE_ALL));
|
||||
collector.checkThat("mEnableTerminateNotification",
|
||||
subscribeConfig.mEnableTerminateNotification, equalTo(true));
|
||||
}
|
||||
@@ -701,14 +699,13 @@ public class WifiAwareManagerTest {
|
||||
final int subscribeType = SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE;
|
||||
final int subscribeCount = 10;
|
||||
final int subscribeTtl = 15;
|
||||
final int matchStyle = SubscribeConfig.MATCH_STYLE_FIRST_ONLY;
|
||||
final boolean enableTerminateNotification = false;
|
||||
|
||||
SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().setServiceName(serviceName)
|
||||
.setServiceSpecificInfo(serviceSpecificInfo.getBytes()).setMatchFilter(
|
||||
new TlvBufferUtils.TlvIterable(0, 1, matchFilter).toList())
|
||||
.setSubscribeType(subscribeType)
|
||||
.setTtlSec(subscribeTtl).setMatchStyle(matchStyle)
|
||||
.setTtlSec(subscribeTtl)
|
||||
.setTerminateNotificationEnabled(enableTerminateNotification).build();
|
||||
|
||||
collector.checkThat("mServiceName", serviceName.getBytes(),
|
||||
@@ -719,7 +716,6 @@ public class WifiAwareManagerTest {
|
||||
collector.checkThat("mSubscribeType", subscribeType,
|
||||
equalTo(subscribeConfig.mSubscribeType));
|
||||
collector.checkThat("mTtlSec", subscribeTtl, equalTo(subscribeConfig.mTtlSec));
|
||||
collector.checkThat("mMatchStyle", matchStyle, equalTo(subscribeConfig.mMatchStyle));
|
||||
collector.checkThat("mEnableTerminateNotification", enableTerminateNotification,
|
||||
equalTo(subscribeConfig.mEnableTerminateNotification));
|
||||
}
|
||||
@@ -730,16 +726,14 @@ public class WifiAwareManagerTest {
|
||||
final String serviceSpecificInfo = "long arbitrary string with some info";
|
||||
final byte[] matchFilter = { 1, 16, 1, 22 };
|
||||
final int subscribeType = SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE;
|
||||
final int subscribeCount = 10;
|
||||
final int subscribeTtl = 15;
|
||||
final int matchStyle = SubscribeConfig.MATCH_STYLE_FIRST_ONLY;
|
||||
final boolean enableTerminateNotification = true;
|
||||
|
||||
SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().setServiceName(serviceName)
|
||||
.setServiceSpecificInfo(serviceSpecificInfo.getBytes()).setMatchFilter(
|
||||
new TlvBufferUtils.TlvIterable(0, 1, matchFilter).toList())
|
||||
.setSubscribeType(subscribeType)
|
||||
.setTtlSec(subscribeTtl).setMatchStyle(matchStyle)
|
||||
.setTtlSec(subscribeTtl)
|
||||
.setTerminateNotificationEnabled(enableTerminateNotification).build();
|
||||
|
||||
Parcel parcelW = Parcel.obtain();
|
||||
@@ -765,14 +759,6 @@ public class WifiAwareManagerTest {
|
||||
new SubscribeConfig.Builder().setTtlSec(-100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a bad match style configuration throws an exception.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSubscribeConfigBuilderBadMatchStyle() {
|
||||
new SubscribeConfig.Builder().setMatchStyle(10);
|
||||
}
|
||||
|
||||
/*
|
||||
* PublishConfig Tests
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user