From 66a3b8c7c09c1b1f587afabd0a7d06801a52fc28 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Thu, 20 Apr 2017 15:54:06 -0700 Subject: [AWARE] Remove match style API Match style (ALL or FIRST) are not necessary - there is no use-case for need to match any but the first time. Match style ALL also has power implications. Bug: 37547045 Test: unit tests + integration (sl4a) tests passing. Change-Id: I6ae872711159f4ade4b2c7cfcd36cd2a0e64dd52 --- api/current.txt | 3 - api/system-current.txt | 3 - api/test-current.txt | 3 - .../android/net/wifi/aware/SubscribeConfig.java | 67 ++-------------------- .../net/wifi/aware/WifiAwareManagerTest.java | 18 +----- 5 files changed, 8 insertions(+), 86 deletions(-) diff --git a/api/current.txt b/api/current.txt index 8cbb9ce9e942..343d0647bcca 100644 --- a/api/current.txt +++ b/api/current.txt @@ -26792,8 +26792,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 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 } @@ -26802,7 +26800,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); - 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); diff --git a/api/system-current.txt b/api/system-current.txt index 58b75374d7a7..6f25c61186c5 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -29536,8 +29536,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 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 } @@ -29546,7 +29544,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); - 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); diff --git a/api/test-current.txt b/api/test-current.txt index 2e401b4cb3a4..f7515e619afe 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -26899,8 +26899,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 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 } @@ -26909,7 +26907,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); - 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); diff --git a/wifi/java/android/net/wifi/aware/SubscribeConfig.java b/wifi/java/android/net/wifi/aware/SubscribeConfig.java index 97a6a3f91e86..6c1fcce5c0b7 100644 --- a/wifi/java/android/net/wifi/aware/SubscribeConfig.java +++ b/wifi/java/android/net/wifi/aware/SubscribeConfig.java @@ -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); } } diff --git a/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java b/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java index 72a6a7a7b46b..14c43fb60599 100644 --- a/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java +++ b/wifi/tests/src/android/net/wifi/aware/WifiAwareManagerTest.java @@ -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 */ -- cgit v1.2.3-59-g8ed1b