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

Commit 9a8e1810 authored by Roshan Pius's avatar Roshan Pius
Browse files

WifiNetworkAgentSpecifier: Allow satisfiedBy call for 2 instances

The specifier created for wifi network agent will end up being compared
with itself whenever there is a capability update sent for example.

Test: ./frameworks/base/wifi/tests/runtests.sh
Test: act.py -c wifi_manager.config -tb dut-name -tc WifiManagerTest
Change-Id: Id8c28fd96ac298df2c17f94476abf9cdbc5d23c9
parent db99b31c
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -99,11 +99,7 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
        if (other instanceof WifiNetworkSpecifier) {
            return satisfiesNetworkSpecifier((WifiNetworkSpecifier) other);
        }
        if (other instanceof WifiNetworkAgentSpecifier) {
            throw new IllegalStateException("WifiNetworkAgentSpecifier instances should never be "
                    + "compared");
        }
        return false;
        return equals(other);
    }

    /**
@@ -172,7 +168,7 @@ public final class WifiNetworkAgentSpecifier extends NetworkSpecifier implements
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("WifiNetworkAgentSpecifier [");
        sb.append(", WifiConfiguration=").append(
        sb.append("WifiConfiguration=").append(
                mWifiConfiguration == null ? null : mWifiConfiguration.configKey())
                .append(", mOriginalRequestorUid=").append(mOriginalRequestorUid)
                .append("]");
+3 −5
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertTrue;
import android.net.MacAddress;
import android.net.MatchAllNetworkSpecifier;
import android.net.NetworkRequest;
import android.net.NetworkSpecifier;
import android.os.Parcel;
import android.os.PatternMatcher;
import android.support.test.filters.SmallTest;
@@ -182,11 +181,10 @@ public class WifiNetworkAgentSpecifierTest {
     * Validate NetworkAgentSpecifier matching with itself.
     * a) Create network agent specifier 1 for WPA_PSK network
     * b) Create network agent specifier 2 with the same params as specifier 1.
     * c) Ensure that invoking {@link NetworkSpecifier#satisfiedBy(NetworkSpecifier)} on 2
     * {@link WifiNetworkAgentSpecifier} throws an exception.
     * c) Ensure that the agent specifier is satisfied by itself.
     */
    @Test(expected = IllegalStateException.class)
    public void testWifiNetworkAgentSpecifierDoesNotSatisifySame() {
    @Test
    public void testWifiNetworkAgentSpecifierDoesSatisifySame() {
        WifiNetworkAgentSpecifier specifier1 = createDefaultNetworkAgentSpecifier();
        WifiNetworkAgentSpecifier specifier2 = createDefaultNetworkAgentSpecifier();