Merge changes from topics "api-fix-networkagent", "satisfiedby"

* changes:
  Rename satisfiedBy into canBeSatisfiedBy
  Address further API council comments.
This commit is contained in:
Chalard Jean
2020-04-02 05:51:02 +00:00
committed by Gerrit Code Review
17 changed files with 76 additions and 75 deletions

View File

@@ -29236,11 +29236,11 @@ package android.net {
} }
public class NetworkRequest implements android.os.Parcelable { public class NetworkRequest implements android.os.Parcelable {
method public boolean canBeSatisfiedBy(@Nullable android.net.NetworkCapabilities);
method public int describeContents(); method public int describeContents();
method @Nullable public android.net.NetworkSpecifier getNetworkSpecifier(); method @Nullable public android.net.NetworkSpecifier getNetworkSpecifier();
method public boolean hasCapability(int); method public boolean hasCapability(int);
method public boolean hasTransport(int); method public boolean hasTransport(int);
method public boolean satisfiedBy(@Nullable android.net.NetworkCapabilities);
method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkRequest> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkRequest> CREATOR;
} }

View File

@@ -4519,7 +4519,6 @@ package android.net {
public final class MatchAllNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable { public final class MatchAllNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable {
ctor public MatchAllNetworkSpecifier(); ctor public MatchAllNetworkSpecifier();
method public int describeContents(); method public int describeContents();
method public boolean satisfiedBy(android.net.NetworkSpecifier);
method public void writeToParcel(@NonNull android.os.Parcel, int); method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.MatchAllNetworkSpecifier> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.net.MatchAllNetworkSpecifier> CREATOR;
} }
@@ -4540,13 +4539,14 @@ package android.net {
public abstract class NetworkAgent { public abstract class NetworkAgent {
ctor public NetworkAgent(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, int, @NonNull android.net.NetworkAgentConfig, @Nullable android.net.NetworkProvider); ctor public NetworkAgent(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, int, @NonNull android.net.NetworkAgentConfig, @Nullable android.net.NetworkProvider);
method @Nullable public android.net.Network getNetwork(); method @Nullable public android.net.Network getNetwork();
method public void markConnected();
method public void onAddKeepalivePacketFilter(int, @NonNull android.net.KeepalivePacketData); method public void onAddKeepalivePacketFilter(int, @NonNull android.net.KeepalivePacketData);
method public void onAutomaticReconnectDisabled(); method public void onAutomaticReconnectDisabled();
method public void onNetworkUnwanted(); method public void onNetworkUnwanted();
method public void onRemoveKeepalivePacketFilter(int); method public void onRemoveKeepalivePacketFilter(int);
method public void onSaveAcceptUnvalidated(boolean); method public void onSaveAcceptUnvalidated(boolean);
method public void onSignalStrengthThresholdsUpdated(@NonNull int[]); method public void onSignalStrengthThresholdsUpdated(@NonNull int[]);
method public void onStartSocketKeepalive(int, @IntRange(from=10, to=3600) int, @NonNull android.net.KeepalivePacketData); method public void onStartSocketKeepalive(int, @NonNull java.time.Duration, @NonNull android.net.KeepalivePacketData);
method public void onStopSocketKeepalive(int); method public void onStopSocketKeepalive(int);
method public void onValidationStatus(int, @Nullable android.net.Uri); method public void onValidationStatus(int, @Nullable android.net.Uri);
method @NonNull public android.net.Network register(); method @NonNull public android.net.Network register();
@@ -4554,7 +4554,6 @@ package android.net {
method public final void sendNetworkCapabilities(@NonNull android.net.NetworkCapabilities); method public final void sendNetworkCapabilities(@NonNull android.net.NetworkCapabilities);
method public final void sendNetworkScore(@IntRange(from=0, to=99) int); method public final void sendNetworkScore(@IntRange(from=0, to=99) int);
method public final void sendSocketKeepaliveEvent(int, int); method public final void sendSocketKeepaliveEvent(int, int);
method public void setConnected();
method public void unregister(); method public void unregister();
field public static final int VALIDATION_STATUS_NOT_VALID = 2; // 0x2 field public static final int VALIDATION_STATUS_NOT_VALID = 2; // 0x2
field public static final int VALIDATION_STATUS_VALID = 1; // 0x1 field public static final int VALIDATION_STATUS_VALID = 1; // 0x1
@@ -4672,8 +4671,8 @@ package android.net {
} }
public abstract class NetworkSpecifier { public abstract class NetworkSpecifier {
method public boolean canBeSatisfiedBy(@Nullable android.net.NetworkSpecifier);
method @Nullable public android.net.NetworkSpecifier redact(); method @Nullable public android.net.NetworkSpecifier redact();
method public abstract boolean satisfiedBy(@Nullable android.net.NetworkSpecifier);
} }
public class NetworkStack { public class NetworkStack {
@@ -4776,10 +4775,6 @@ package android.net {
method @NonNull public android.net.StaticIpConfiguration.Builder setIpAddress(@Nullable android.net.LinkAddress); method @NonNull public android.net.StaticIpConfiguration.Builder setIpAddress(@Nullable android.net.LinkAddress);
} }
public final class TelephonyNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable {
method public boolean satisfiedBy(android.net.NetworkSpecifier);
}
public final class TetheredClient implements android.os.Parcelable { public final class TetheredClient implements android.os.Parcelable {
ctor public TetheredClient(@NonNull android.net.MacAddress, @NonNull java.util.Collection<android.net.TetheredClient.AddressInfo>, int); ctor public TetheredClient(@NonNull android.net.MacAddress, @NonNull java.util.Collection<android.net.TetheredClient.AddressInfo>, int);
method public int describeContents(); method public int describeContents();
@@ -5470,10 +5465,6 @@ package android.net.wifi {
field public int numUsage; field public int numUsage;
} }
public final class WifiNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable {
method public boolean satisfiedBy(android.net.NetworkSpecifier);
}
public class WifiScanner { public class WifiScanner {
method @Deprecated public void configureWifiChange(int, int, int, int, int, android.net.wifi.WifiScanner.BssidInfo[]); method @Deprecated public void configureWifiChange(int, int, int, int, int, android.net.wifi.WifiScanner.BssidInfo[]);
method @Deprecated public void configureWifiChange(android.net.wifi.WifiScanner.WifiChangeSettings); method @Deprecated public void configureWifiChange(android.net.wifi.WifiScanner.WifiChangeSettings);
@@ -5638,10 +5629,6 @@ package android.net.wifi.aware {
method @Deprecated public android.net.NetworkSpecifier createNetworkSpecifierPmk(@NonNull android.net.wifi.aware.PeerHandle, @NonNull byte[]); method @Deprecated public android.net.NetworkSpecifier createNetworkSpecifierPmk(@NonNull android.net.wifi.aware.PeerHandle, @NonNull byte[]);
} }
public final class WifiAwareNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable {
method public boolean satisfiedBy(android.net.NetworkSpecifier);
}
public static final class WifiAwareNetworkSpecifier.Builder { public static final class WifiAwareNetworkSpecifier.Builder {
method @NonNull public android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder setPmk(@NonNull byte[]); method @NonNull public android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder setPmk(@NonNull byte[]);
} }

View File

@@ -36,6 +36,7 @@ import com.android.internal.util.Protocol;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@@ -47,7 +48,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* An agent manages the life cycle of a network. A network starts its * An agent manages the life cycle of a network. A network starts its
* life cycle when {@link register} is called on NetworkAgent. The network * life cycle when {@link register} is called on NetworkAgent. The network
* is then connecting. When full L3 connectivity has been established, * is then connecting. When full L3 connectivity has been established,
* the agent shoud call {@link setConnected} to inform the system that * the agent shoud call {@link markConnected} to inform the system that
* this network is ready to use. When the network disconnects its life * this network is ready to use. When the network disconnects its life
* ends and the agent should call {@link unregister}, at which point the * ends and the agent should call {@link unregister}, at which point the
* system will clean up and free resources. * system will clean up and free resources.
@@ -503,7 +504,8 @@ public abstract class NetworkAgent {
break; break;
} }
case CMD_START_SOCKET_KEEPALIVE: { case CMD_START_SOCKET_KEEPALIVE: {
onStartSocketKeepalive(msg.arg1 /* slot */, msg.arg2 /* interval */, onStartSocketKeepalive(msg.arg1 /* slot */,
Duration.ofSeconds(msg.arg2) /* interval */,
(KeepalivePacketData) msg.obj /* packet */); (KeepalivePacketData) msg.obj /* packet */);
break; break;
} }
@@ -617,10 +619,10 @@ public abstract class NetworkAgent {
* Inform ConnectivityService that this agent has now connected. * Inform ConnectivityService that this agent has now connected.
* Call {@link #unregister} to disconnect. * Call {@link #unregister} to disconnect.
*/ */
public void setConnected() { public void markConnected() {
if (mIsLegacy) { if (mIsLegacy) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Legacy agents can't call setConnected."); "Legacy agents can't call markConnected.");
} }
mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null); mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
queueOrSendMessage(EVENT_NETWORK_INFO_CHANGED, mNetworkInfo); queueOrSendMessage(EVENT_NETWORK_INFO_CHANGED, mNetworkInfo);
@@ -798,8 +800,8 @@ public abstract class NetworkAgent {
* {@code VALIDATION_STATUS_VALID} if Internet connectivity was validated, * {@code VALIDATION_STATUS_VALID} if Internet connectivity was validated,
* {@code VALIDATION_STATUS_NOT_VALID} if Internet connectivity was not validated. * {@code VALIDATION_STATUS_NOT_VALID} if Internet connectivity was not validated.
* *
* This may be called multiple times as network status changes, or if there are multiple * This is guaranteed to be called again when the network status changes, but the system
* subsequent attempts to validate connectivity that fail. * may also call this multiple times even if the status does not change.
* *
* @param status one of {@code VALIDATION_STATUS_VALID} or {@code VALIDATION_STATUS_NOT_VALID}. * @param status one of {@code VALIDATION_STATUS_VALID} or {@code VALIDATION_STATUS_NOT_VALID}.
* @param redirectUri If Internet connectivity is being redirected (e.g., on a captive portal), * @param redirectUri If Internet connectivity is being redirected (e.g., on a captive portal),
@@ -832,18 +834,25 @@ public abstract class NetworkAgent {
* Requests that the network hardware send the specified packet at the specified interval. * Requests that the network hardware send the specified packet at the specified interval.
* *
* @param slot the hardware slot on which to start the keepalive. * @param slot the hardware slot on which to start the keepalive.
* @param intervalSeconds the interval between packets * @param interval the interval between packets, between 10 and 3600. Note that this API
* does not support sub-second precision and will round off the request.
* @param packet the packet to send. * @param packet the packet to send.
*/ */
// seconds is from SocketKeepalive.MIN_INTERVAL_SEC to MAX_INTERVAL_SEC, but these should // seconds is from SocketKeepalive.MIN_INTERVAL_SEC to MAX_INTERVAL_SEC, but these should
// not be exposed as constants because they may change in the future (API guideline 4.8) // not be exposed as constants because they may change in the future (API guideline 4.8)
// and should have getters if exposed at all. Getters can't be used in the annotation, // and should have getters if exposed at all. Getters can't be used in the annotation,
// so the values unfortunately need to be copied. // so the values unfortunately need to be copied.
public void onStartSocketKeepalive(int slot, public void onStartSocketKeepalive(int slot, @NonNull Duration interval,
@IntRange(from = 10, to = 3600) int intervalSeconds,
@NonNull KeepalivePacketData packet) { @NonNull KeepalivePacketData packet) {
Message msg = mHandler.obtainMessage(CMD_START_SOCKET_KEEPALIVE, slot, intervalSeconds, final long intervalSeconds = interval.getSeconds();
packet); if (intervalSeconds < SocketKeepalive.MIN_INTERVAL_SEC
|| intervalSeconds > SocketKeepalive.MAX_INTERVAL_SEC) {
throw new IllegalArgumentException("Interval needs to be comprised between "
+ SocketKeepalive.MIN_INTERVAL_SEC + " and " + SocketKeepalive.MAX_INTERVAL_SEC
+ " but was " + intervalSeconds);
}
final Message msg = mHandler.obtainMessage(CMD_START_SOCKET_KEEPALIVE, slot,
(int) intervalSeconds, packet);
startSocketKeepalive(msg); startSocketKeepalive(msg);
msg.recycle(); msg.recycle();
} }

View File

@@ -1177,7 +1177,7 @@ public final class NetworkCapabilities implements Parcelable {
} }
private boolean satisfiedBySpecifier(NetworkCapabilities nc) { private boolean satisfiedBySpecifier(NetworkCapabilities nc) {
return mNetworkSpecifier == null || mNetworkSpecifier.satisfiedBy(nc.mNetworkSpecifier) return mNetworkSpecifier == null || mNetworkSpecifier.canBeSatisfiedBy(nc.mNetworkSpecifier)
|| nc.mNetworkSpecifier instanceof MatchAllNetworkSpecifier; || nc.mNetworkSpecifier instanceof MatchAllNetworkSpecifier;
} }

View File

@@ -474,7 +474,7 @@ public class NetworkRequest implements Parcelable {
* @param nc Capabilities that should satisfy this NetworkRequest. null capabilities do not * @param nc Capabilities that should satisfy this NetworkRequest. null capabilities do not
* satisfy any request. * satisfy any request.
*/ */
public boolean satisfiedBy(@Nullable NetworkCapabilities nc) { public boolean canBeSatisfiedBy(@Nullable NetworkCapabilities nc) {
return networkCapabilities.satisfiedByNetworkCapabilities(nc); return networkCapabilities.satisfiedByNetworkCapabilities(nc);
} }

View File

@@ -35,7 +35,9 @@ public abstract class NetworkSpecifier {
* @hide * @hide
*/ */
@SystemApi @SystemApi
public abstract boolean satisfiedBy(@Nullable NetworkSpecifier other); public boolean canBeSatisfiedBy(@Nullable NetworkSpecifier other) {
return false;
}
/** /**
* Optional method which can be overridden by concrete implementations of NetworkSpecifier to * Optional method which can be overridden by concrete implementations of NetworkSpecifier to

View File

@@ -115,7 +115,8 @@ public abstract class SocketKeepalive implements AutoCloseable {
SUCCESS, SUCCESS,
ERROR_INVALID_LENGTH, ERROR_INVALID_LENGTH,
ERROR_UNSUPPORTED, ERROR_UNSUPPORTED,
ERROR_INSUFFICIENT_RESOURCES ERROR_INSUFFICIENT_RESOURCES,
ERROR_HARDWARE_UNSUPPORTED
}) })
public @interface KeepaliveEvent {} public @interface KeepaliveEvent {}

View File

@@ -40,7 +40,7 @@ public final class StringNetworkSpecifier extends NetworkSpecifier implements Pa
/** @hide */ /** @hide */
@Override @Override
public boolean satisfiedBy(NetworkSpecifier other) { public boolean canBeSatisfiedBy(NetworkSpecifier other) {
return equals(other); return equals(other);
} }

View File

@@ -97,7 +97,7 @@ public final class TelephonyNetworkSpecifier extends NetworkSpecifier implements
/** @hide */ /** @hide */
@Override @Override
public boolean satisfiedBy(NetworkSpecifier other) { public boolean canBeSatisfiedBy(NetworkSpecifier other) {
// Any generic requests should be satisfied by a specific telephony network. // Any generic requests should be satisfied by a specific telephony network.
// For simplicity, we treat null same as MatchAllNetworkSpecifier // For simplicity, we treat null same as MatchAllNetworkSpecifier
return equals(other) || other == null || other instanceof MatchAllNetworkSpecifier; return equals(other) || other == null || other instanceof MatchAllNetworkSpecifier;

View File

@@ -2913,7 +2913,7 @@ public class ConnectivityServiceTest {
class ConfidentialMatchAllNetworkSpecifier extends NetworkSpecifier implements class ConfidentialMatchAllNetworkSpecifier extends NetworkSpecifier implements
Parcelable { Parcelable {
@Override @Override
public boolean satisfiedBy(NetworkSpecifier other) { public boolean canBeSatisfiedBy(NetworkSpecifier other) {
return true; return true;
} }
@@ -2941,7 +2941,7 @@ public class ConnectivityServiceTest {
} }
@Override @Override
public boolean satisfiedBy(NetworkSpecifier other) { public boolean canBeSatisfiedBy(NetworkSpecifier other) {
if (other instanceof LocalStringNetworkSpecifier) { if (other instanceof LocalStringNetworkSpecifier) {
return TextUtils.equals(mString, return TextUtils.equals(mString,
((LocalStringNetworkSpecifier) other).mString); ((LocalStringNetworkSpecifier) other).mString);
@@ -3062,7 +3062,10 @@ public class ConnectivityServiceTest {
}); });
class NonParcelableSpecifier extends NetworkSpecifier { class NonParcelableSpecifier extends NetworkSpecifier {
public boolean satisfiedBy(NetworkSpecifier other) { return false; } @Override
public boolean canBeSatisfiedBy(NetworkSpecifier other) {
return false;
}
}; };
class ParcelableSpecifier extends NonParcelableSpecifier implements Parcelable { class ParcelableSpecifier extends NonParcelableSpecifier implements Parcelable {
@Override public int describeContents() { return 0; } @Override public int describeContents() { return 0; }

View File

@@ -104,7 +104,7 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
} }
@Override @Override
public boolean satisfiedBy(@Nullable NetworkSpecifier other) { public boolean canBeSatisfiedBy(@Nullable NetworkSpecifier other) {
if (this == other) { if (this == other) {
return true; return true;
} }

View File

@@ -583,7 +583,7 @@ public final class WifiNetworkSpecifier extends NetworkSpecifier implements Parc
/** @hide */ /** @hide */
@Override @Override
public boolean satisfiedBy(NetworkSpecifier other) { public boolean canBeSatisfiedBy(NetworkSpecifier other) {
if (this == other) { if (this == other) {
return true; return true;
} }

View File

@@ -121,7 +121,7 @@ public class WifiAwareAgentNetworkSpecifier extends NetworkSpecifier implements
} }
@Override @Override
public boolean satisfiedBy(NetworkSpecifier other) { public boolean canBeSatisfiedBy(NetworkSpecifier other) {
if (!(other instanceof WifiAwareAgentNetworkSpecifier)) { if (!(other instanceof WifiAwareAgentNetworkSpecifier)) {
return false; return false;
} }

View File

@@ -227,7 +227,7 @@ public final class WifiAwareNetworkSpecifier extends NetworkSpecifier implements
/** @hide */ /** @hide */
@Override @Override
public boolean satisfiedBy(NetworkSpecifier other) { public boolean canBeSatisfiedBy(NetworkSpecifier other) {
// MatchAllNetworkSpecifier is taken care in NetworkCapabilities#satisfiedBySpecifier. // MatchAllNetworkSpecifier is taken care in NetworkCapabilities#satisfiedBySpecifier.
if (other instanceof WifiAwareAgentNetworkSpecifier) { if (other instanceof WifiAwareAgentNetworkSpecifier) {
return ((WifiAwareAgentNetworkSpecifier) other).satisfiesAwareNetworkSpecifier(this); return ((WifiAwareAgentNetworkSpecifier) other).satisfiesAwareNetworkSpecifier(this);

View File

@@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
import android.net.MacAddress; import android.net.MacAddress;
import android.net.MatchAllNetworkSpecifier; import android.net.MatchAllNetworkSpecifier;
import android.net.NetworkRequest;
import android.os.Parcel; import android.os.Parcel;
import android.os.PatternMatcher; import android.os.PatternMatcher;
import android.util.Pair; import android.util.Pair;
@@ -166,8 +165,8 @@ public class WifiNetworkAgentSpecifierTest {
public void testWifiNetworkAgentSpecifierSatisifiesNullAndAllMatch() { public void testWifiNetworkAgentSpecifierSatisifiesNullAndAllMatch() {
WifiNetworkAgentSpecifier specifier = createDefaultNetworkAgentSpecifier(); WifiNetworkAgentSpecifier specifier = createDefaultNetworkAgentSpecifier();
assertTrue(specifier.satisfiedBy(null)); assertTrue(specifier.canBeSatisfiedBy(null));
assertTrue(specifier.satisfiedBy(new MatchAllNetworkSpecifier())); assertTrue(specifier.canBeSatisfiedBy(new MatchAllNetworkSpecifier()));
} }
/** /**
@@ -181,7 +180,7 @@ public class WifiNetworkAgentSpecifierTest {
WifiNetworkAgentSpecifier specifier1 = createDefaultNetworkAgentSpecifier(); WifiNetworkAgentSpecifier specifier1 = createDefaultNetworkAgentSpecifier();
WifiNetworkAgentSpecifier specifier2 = createDefaultNetworkAgentSpecifier(); WifiNetworkAgentSpecifier specifier2 = createDefaultNetworkAgentSpecifier();
assertTrue(specifier2.satisfiedBy(specifier1)); assertTrue(specifier2.canBeSatisfiedBy(specifier1));
} }
/** /**
@@ -208,8 +207,8 @@ public class WifiNetworkAgentSpecifierTest {
wificonfigurationNetworkSpecifier, wificonfigurationNetworkSpecifier,
TEST_UID, TEST_PACKAGE); TEST_UID, TEST_PACKAGE);
assertTrue(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier)); assertTrue(wifiNetworkSpecifier.canBeSatisfiedBy(wifiNetworkAgentSpecifier));
assertTrue(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier)); assertTrue(wifiNetworkAgentSpecifier.canBeSatisfiedBy(wifiNetworkSpecifier));
} }
/** /**
@@ -237,8 +236,8 @@ public class WifiNetworkAgentSpecifierTest {
wificonfigurationNetworkSpecifier, wificonfigurationNetworkSpecifier,
TEST_UID, TEST_PACKAGE); TEST_UID, TEST_PACKAGE);
assertTrue(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier)); assertTrue(wifiNetworkSpecifier.canBeSatisfiedBy(wifiNetworkAgentSpecifier));
assertTrue(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier)); assertTrue(wifiNetworkAgentSpecifier.canBeSatisfiedBy(wifiNetworkSpecifier));
} }
/** /**
@@ -266,8 +265,8 @@ public class WifiNetworkAgentSpecifierTest {
wificonfigurationNetworkSpecifier, wificonfigurationNetworkSpecifier,
TEST_UID, TEST_PACKAGE); TEST_UID, TEST_PACKAGE);
assertTrue(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier)); assertTrue(wifiNetworkSpecifier.canBeSatisfiedBy(wifiNetworkAgentSpecifier));
assertTrue(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier)); assertTrue(wifiNetworkAgentSpecifier.canBeSatisfiedBy(wifiNetworkSpecifier));
} }
/** /**
@@ -299,8 +298,8 @@ public class WifiNetworkAgentSpecifierTest {
wificonfigurationNetworkSpecifier, wificonfigurationNetworkSpecifier,
TEST_UID, TEST_PACKAGE); TEST_UID, TEST_PACKAGE);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier)); assertFalse(wifiNetworkSpecifier.canBeSatisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier)); assertFalse(wifiNetworkAgentSpecifier.canBeSatisfiedBy(wifiNetworkSpecifier));
} }
/** /**
@@ -333,8 +332,8 @@ public class WifiNetworkAgentSpecifierTest {
wificonfigurationNetworkSpecifier, wificonfigurationNetworkSpecifier,
TEST_UID, TEST_PACKAGE); TEST_UID, TEST_PACKAGE);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier)); assertFalse(wifiNetworkSpecifier.canBeSatisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier)); assertFalse(wifiNetworkAgentSpecifier.canBeSatisfiedBy(wifiNetworkSpecifier));
} }
/** /**
@@ -367,8 +366,8 @@ public class WifiNetworkAgentSpecifierTest {
wificonfigurationNetworkSpecifier, wificonfigurationNetworkSpecifier,
TEST_UID, TEST_PACKAGE); TEST_UID, TEST_PACKAGE);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier)); assertFalse(wifiNetworkSpecifier.canBeSatisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier)); assertFalse(wifiNetworkAgentSpecifier.canBeSatisfiedBy(wifiNetworkSpecifier));
} }
/** /**
@@ -395,8 +394,8 @@ public class WifiNetworkAgentSpecifierTest {
wificonfigurationNetworkSpecifier, wificonfigurationNetworkSpecifier,
TEST_UID, TEST_PACKAGE); TEST_UID, TEST_PACKAGE);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier)); assertFalse(wifiNetworkSpecifier.canBeSatisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier)); assertFalse(wifiNetworkAgentSpecifier.canBeSatisfiedBy(wifiNetworkSpecifier));
} }
/** /**
@@ -424,8 +423,8 @@ public class WifiNetworkAgentSpecifierTest {
wificonfigurationNetworkSpecifier, wificonfigurationNetworkSpecifier,
TEST_UID_1, TEST_PACKAGE_1); TEST_UID_1, TEST_PACKAGE_1);
assertFalse(wifiNetworkSpecifier.satisfiedBy(wifiNetworkAgentSpecifier)); assertFalse(wifiNetworkSpecifier.canBeSatisfiedBy(wifiNetworkAgentSpecifier));
assertFalse(wifiNetworkAgentSpecifier.satisfiedBy(wifiNetworkSpecifier)); assertFalse(wifiNetworkAgentSpecifier.canBeSatisfiedBy(wifiNetworkSpecifier));
} }
private WifiConfiguration createDefaultWifiConfiguration() { private WifiConfiguration createDefaultWifiConfiguration() {

View File

@@ -399,8 +399,8 @@ public class WifiNetworkSpecifierTest {
wifiConfiguration, wifiConfiguration,
TEST_UID, TEST_PACKAGE_NAME); TEST_UID, TEST_PACKAGE_NAME);
assertTrue(specifier.satisfiedBy(null)); assertTrue(specifier.canBeSatisfiedBy(null));
assertTrue(specifier.satisfiedBy(new MatchAllNetworkSpecifier())); assertTrue(specifier.canBeSatisfiedBy(new MatchAllNetworkSpecifier()));
} }
/** /**
@@ -429,7 +429,7 @@ public class WifiNetworkSpecifierTest {
wifiConfiguration, wifiConfiguration,
TEST_UID, TEST_PACKAGE_NAME); TEST_UID, TEST_PACKAGE_NAME);
assertTrue(specifier2.satisfiedBy(specifier1)); assertTrue(specifier2.canBeSatisfiedBy(specifier1));
} }
/** /**
@@ -460,7 +460,7 @@ public class WifiNetworkSpecifierTest {
wifiConfiguration2, wifiConfiguration2,
TEST_UID, TEST_PACKAGE_NAME); TEST_UID, TEST_PACKAGE_NAME);
assertFalse(specifier2.satisfiedBy(specifier1)); assertFalse(specifier2.canBeSatisfiedBy(specifier1));
} }
/** /**
@@ -489,7 +489,7 @@ public class WifiNetworkSpecifierTest {
wifiConfiguration, wifiConfiguration,
TEST_UID, TEST_PACKAGE_NAME); TEST_UID, TEST_PACKAGE_NAME);
assertFalse(specifier2.satisfiedBy(specifier1)); assertFalse(specifier2.canBeSatisfiedBy(specifier1));
} }
/** /**
@@ -517,7 +517,7 @@ public class WifiNetworkSpecifierTest {
wifiConfiguration, wifiConfiguration,
TEST_UID, TEST_PACKAGE_NAME); TEST_UID, TEST_PACKAGE_NAME);
assertFalse(specifier2.satisfiedBy(specifier1)); assertFalse(specifier2.canBeSatisfiedBy(specifier1));
} }
/** /**
@@ -546,6 +546,6 @@ public class WifiNetworkSpecifierTest {
wifiConfiguration, wifiConfiguration,
TEST_UID, TEST_PACKAGE_NAME + "blah"); TEST_UID, TEST_PACKAGE_NAME + "blah");
assertFalse(specifier2.satisfiedBy(specifier1)); assertFalse(specifier2.canBeSatisfiedBy(specifier1));
} }
} }

View File

@@ -79,7 +79,7 @@ public class WifiAwareAgentNetworkSpecifierTest {
public void testEmptyDoesntMatchAnything() { public void testEmptyDoesntMatchAnything() {
WifiAwareAgentNetworkSpecifier dut = new WifiAwareAgentNetworkSpecifier(); WifiAwareAgentNetworkSpecifier dut = new WifiAwareAgentNetworkSpecifier();
WifiAwareNetworkSpecifier ns = getDummyNetworkSpecifier(6); WifiAwareNetworkSpecifier ns = getDummyNetworkSpecifier(6);
collector.checkThat("No match expected", ns.satisfiedBy(dut), equalTo(false)); collector.checkThat("No match expected", ns.canBeSatisfiedBy(dut), equalTo(false));
} }
/** /**
@@ -91,8 +91,8 @@ public class WifiAwareAgentNetworkSpecifierTest {
WifiAwareNetworkSpecifier nsThis = getDummyNetworkSpecifier(6); WifiAwareNetworkSpecifier nsThis = getDummyNetworkSpecifier(6);
WifiAwareAgentNetworkSpecifier dut = new WifiAwareAgentNetworkSpecifier(nsThis); WifiAwareAgentNetworkSpecifier dut = new WifiAwareAgentNetworkSpecifier(nsThis);
WifiAwareNetworkSpecifier nsOther = getDummyNetworkSpecifier(8); WifiAwareNetworkSpecifier nsOther = getDummyNetworkSpecifier(8);
collector.checkThat("Match expected", nsThis.satisfiedBy(dut), equalTo(true)); collector.checkThat("Match expected", nsThis.canBeSatisfiedBy(dut), equalTo(true));
collector.checkThat("No match expected", nsOther.satisfiedBy(dut), equalTo(false)); collector.checkThat("No match expected", nsOther.canBeSatisfiedBy(dut), equalTo(false));
} }
/** /**
@@ -113,9 +113,9 @@ public class WifiAwareAgentNetworkSpecifierTest {
WifiAwareNetworkSpecifier nsOther = getDummyNetworkSpecifier(10000); WifiAwareNetworkSpecifier nsOther = getDummyNetworkSpecifier(10000);
for (WifiAwareNetworkSpecifier nsThis: nsSet) { for (WifiAwareNetworkSpecifier nsThis: nsSet) {
collector.checkThat("Match expected", nsThis.satisfiedBy(dut), equalTo(true)); collector.checkThat("Match expected", nsThis.canBeSatisfiedBy(dut), equalTo(true));
} }
collector.checkThat("No match expected", nsOther.satisfiedBy(dut), equalTo(false)); collector.checkThat("No match expected", nsOther.canBeSatisfiedBy(dut), equalTo(false));
} }
/** /**
@@ -137,7 +137,7 @@ public class WifiAwareAgentNetworkSpecifierTest {
WifiAwareAgentNetworkSpecifier newNs = new WifiAwareAgentNetworkSpecifier( WifiAwareAgentNetworkSpecifier newNs = new WifiAwareAgentNetworkSpecifier(
nsSet.toArray(new WifiAwareNetworkSpecifier[nsSet.size()])); nsSet.toArray(new WifiAwareNetworkSpecifier[nsSet.size()]));
collector.checkThat("Match expected", oldNs.satisfiedBy(newNs), equalTo(true)); collector.checkThat("Match expected", oldNs.canBeSatisfiedBy(newNs), equalTo(true));
} }
/** /**
@@ -159,7 +159,7 @@ public class WifiAwareAgentNetworkSpecifierTest {
WifiAwareAgentNetworkSpecifier oldNs = new WifiAwareAgentNetworkSpecifier( WifiAwareAgentNetworkSpecifier oldNs = new WifiAwareAgentNetworkSpecifier(
nsSet.toArray(new WifiAwareNetworkSpecifier[nsSet.size()])); nsSet.toArray(new WifiAwareNetworkSpecifier[nsSet.size()]));
collector.checkThat("Match unexpected", oldNs.satisfiedBy(newNs), equalTo(false)); collector.checkThat("Match unexpected", oldNs.canBeSatisfiedBy(newNs), equalTo(false));
} }
// utilities // utilities