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

Commit 55c89d19 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Automerger Merge Worker
Browse files

Merge "Set extraInfo on cellular TestNetworkAgents." am: f0f69b46

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1624039

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I66af2cf6b6cd286993fa3328c5cc52d8bba3beb9
parents 8ec1bd69 f0f69b46
Loading
Loading
Loading
Loading
+21 −8
Original line number Original line Diff line number Diff line
@@ -64,6 +64,7 @@ public class NetworkAgentWrapper implements TestableNetworkCallback.HasNetwork {
    private final HandlerThread mHandlerThread;
    private final HandlerThread mHandlerThread;
    private final Context mContext;
    private final Context mContext;
    private final String mLogTag;
    private final String mLogTag;
    private final NetworkAgentConfig mNetworkAgentConfig;


    private final ConditionVariable mDisconnected = new ConditionVariable();
    private final ConditionVariable mDisconnected = new ConditionVariable();
    private final ConditionVariable mPreventReconnectReceived = new ConditionVariable();
    private final ConditionVariable mPreventReconnectReceived = new ConditionVariable();
@@ -115,13 +116,19 @@ public class NetworkAgentWrapper implements TestableNetworkCallback.HasNetwork {
        mHandlerThread = new HandlerThread(mLogTag);
        mHandlerThread = new HandlerThread(mLogTag);
        mHandlerThread.start();
        mHandlerThread.start();


        mNetworkAgent = makeNetworkAgent(linkProperties, type, typeName);
        // extraInfo is set to "" by default in NetworkAgentConfig.
        final String extraInfo = (transport == TRANSPORT_CELLULAR) ? "internet.apn" : "";
        mNetworkAgentConfig = new NetworkAgentConfig.Builder()
                .setLegacyType(type)
                .setLegacyTypeName(typeName)
                .setLegacyExtraInfo(extraInfo)
                .build();
        mNetworkAgent = makeNetworkAgent(linkProperties, mNetworkAgentConfig);
    }
    }


    protected InstrumentedNetworkAgent makeNetworkAgent(LinkProperties linkProperties,
    protected InstrumentedNetworkAgent makeNetworkAgent(LinkProperties linkProperties,
            final int type, final String typeName)
            final NetworkAgentConfig nac) throws Exception {
            throws Exception {
        return new InstrumentedNetworkAgent(this, linkProperties, nac);
        return new InstrumentedNetworkAgent(this, linkProperties, type, typeName);
    }
    }


    public static class InstrumentedNetworkAgent extends NetworkAgent {
    public static class InstrumentedNetworkAgent extends NetworkAgent {
@@ -129,11 +136,9 @@ public class NetworkAgentWrapper implements TestableNetworkCallback.HasNetwork {
        private static final String PROVIDER_NAME = "InstrumentedNetworkAgentProvider";
        private static final String PROVIDER_NAME = "InstrumentedNetworkAgentProvider";


        public InstrumentedNetworkAgent(NetworkAgentWrapper wrapper, LinkProperties lp,
        public InstrumentedNetworkAgent(NetworkAgentWrapper wrapper, LinkProperties lp,
                final int type, final String typeName) {
                NetworkAgentConfig nac) {
            super(wrapper.mContext, wrapper.mHandlerThread.getLooper(), wrapper.mLogTag,
            super(wrapper.mContext, wrapper.mHandlerThread.getLooper(), wrapper.mLogTag,
                    wrapper.mNetworkCapabilities, lp, wrapper.mScore,
                    wrapper.mNetworkCapabilities, lp, wrapper.mScore, nac,
                    new NetworkAgentConfig.Builder()
                            .setLegacyType(type).setLegacyTypeName(typeName).build(),
                    new NetworkProvider(wrapper.mContext, wrapper.mHandlerThread.getLooper(),
                    new NetworkProvider(wrapper.mContext, wrapper.mHandlerThread.getLooper(),
                            PROVIDER_NAME));
                            PROVIDER_NAME));
            mWrapper = wrapper;
            mWrapper = wrapper;
@@ -301,6 +306,14 @@ public class NetworkAgentWrapper implements TestableNetworkCallback.HasNetwork {
        return mNetworkCapabilities;
        return mNetworkCapabilities;
    }
    }


    public int getLegacyType() {
        return mNetworkAgentConfig.getLegacyType();
    }

    public String getExtraInfo() {
        return mNetworkAgentConfig.getLegacyExtraInfo();
    }

    public @NonNull ArrayTrackRecord<CallbackType>.ReadHead getCallbackHistory() {
    public @NonNull ArrayTrackRecord<CallbackType>.ReadHead getCallbackHistory() {
        return mCallbackHistory;
        return mCallbackHistory;
    }
    }
+3 −3
Original line number Original line Diff line number Diff line
@@ -718,7 +718,7 @@ public class ConnectivityServiceTest {
        @Override
        @Override
        protected InstrumentedNetworkAgent makeNetworkAgent(LinkProperties linkProperties,
        protected InstrumentedNetworkAgent makeNetworkAgent(LinkProperties linkProperties,
                final int type, final String typeName) throws Exception {
                NetworkAgentConfig nac) throws Exception {
            mNetworkMonitor = mock(INetworkMonitor.class);
            mNetworkMonitor = mock(INetworkMonitor.class);
            final Answer validateAnswer = inv -> {
            final Answer validateAnswer = inv -> {
@@ -737,8 +737,8 @@ public class ConnectivityServiceTest {
                    any() /* name */,
                    any() /* name */,
                    nmCbCaptor.capture());
                    nmCbCaptor.capture());
            final InstrumentedNetworkAgent na = new InstrumentedNetworkAgent(this, linkProperties,
            final InstrumentedNetworkAgent na =
                    type, typeName) {
                    new InstrumentedNetworkAgent(this, linkProperties, nac) {
                @Override
                @Override
                public void networkStatus(int status, String redirectUrl) {
                public void networkStatus(int status, String redirectUrl) {
                    mRedirectUrl = redirectUrl;
                    mRedirectUrl = redirectUrl;