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

Commit 21907e1c authored by Chalard Jean's avatar Chalard Jean Committed by Gerrit Code Review
Browse files

Merge "Send the capport fields to the system server."

parents 6d269046 b3e46dad
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -62,4 +62,10 @@ public class NetworkInformationShimImpl implements NetworkInformationShim {
        // Not supported on this API level
        return null;
    }

    @NonNull
    @Override
    public LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull final LinkProperties lp) {
        return new LinkProperties(lp);
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -59,4 +59,10 @@ public class NetworkInformationShimImpl extends
        if (nc == null) return null;
        return nc.getSSID();
    }

    @NonNull
    @Override
    public LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull final LinkProperties lp) {
        return lp.makeSensitiveFieldsParcelingCopy();
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -44,4 +44,10 @@ public interface NetworkInformationShim {
     */
    @Nullable
    String getSSID(@Nullable NetworkCapabilities nc);

    /**
     * @see LinkProperties#makeSensitiveFieldsParcelingCopy()
     */
    @NonNull
    LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull LinkProperties lp);
}
+15 −9
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ import com.android.internal.util.Preconditions;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.internal.util.WakeupMessage;
import com.android.networkstack.apishim.NetworkInformationShim;
import com.android.networkstack.apishim.NetworkInformationShimImpl;
import com.android.networkstack.apishim.ShimUtils;
import com.android.server.NetworkObserverRegistry;
import com.android.server.NetworkStackService.NetworkStackServiceManager;
@@ -112,6 +114,7 @@ public class IpClient extends StateMachine {
    private static final ConcurrentHashMap<String, SharedLog> sSmLogs = new ConcurrentHashMap<>();
    private static final ConcurrentHashMap<String, LocalLog> sPktLogs = new ConcurrentHashMap<>();
    private final NetworkStackIpMemoryStore mIpMemoryStore;
    private final NetworkInformationShim mShim = NetworkInformationShimImpl.newInstance();

    /**
     * Dump all state machine and connectivity packet logs to the specified writer.
@@ -165,11 +168,15 @@ public class IpClient extends StateMachine {
        private static final String PREFIX = "INVOKE ";
        private final IIpClientCallbacks mCallback;
        private final SharedLog mLog;
        @NonNull
        private final NetworkInformationShim mShim;

        @VisibleForTesting
        protected IpClientCallbacksWrapper(IIpClientCallbacks callback, SharedLog log) {
        protected IpClientCallbacksWrapper(IIpClientCallbacks callback, SharedLog log,
                @NonNull NetworkInformationShim shim) {
            mCallback = callback;
            mLog = log;
            mShim = shim;
        }

        private void log(String msg) {
@@ -224,7 +231,7 @@ public class IpClient extends StateMachine {
        public void onProvisioningSuccess(LinkProperties newLp) {
            log("onProvisioningSuccess({" + newLp + "})");
            try {
                mCallback.onProvisioningSuccess(newLp);
                mCallback.onProvisioningSuccess(mShim.makeSensitiveFieldsParcelingCopy(newLp));
            } catch (RemoteException e) {
                log("Failed to call onProvisioningSuccess", e);
            }
@@ -236,7 +243,7 @@ public class IpClient extends StateMachine {
        public void onProvisioningFailure(LinkProperties newLp) {
            log("onProvisioningFailure({" + newLp + "})");
            try {
                mCallback.onProvisioningFailure(newLp);
                mCallback.onProvisioningFailure(mShim.makeSensitiveFieldsParcelingCopy(newLp));
            } catch (RemoteException e) {
                log("Failed to call onProvisioningFailure", e);
            }
@@ -248,7 +255,7 @@ public class IpClient extends StateMachine {
        public void onLinkPropertiesChange(LinkProperties newLp) {
            log("onLinkPropertiesChange({" + newLp + "})");
            try {
                mCallback.onLinkPropertiesChange(newLp);
                mCallback.onLinkPropertiesChange(mShim.makeSensitiveFieldsParcelingCopy(newLp));
            } catch (RemoteException e) {
                log("Failed to call onLinkPropertiesChange", e);
            }
@@ -530,7 +537,7 @@ public class IpClient extends StateMachine {
        sPktLogs.putIfAbsent(mInterfaceName, new LocalLog(MAX_PACKET_RECORDS));
        mConnectivityPacketLog = sPktLogs.get(mInterfaceName);
        mMsgStateLogger = new MessageHandlingLogger();
        mCallback = new IpClientCallbacksWrapper(callback, mLog);
        mCallback = new IpClientCallbacksWrapper(callback, mLog, mShim);

        // TODO: Consider creating, constructing, and passing in some kind of
        // InterfaceController.Dependencies class.
@@ -1302,7 +1309,7 @@ public class IpClient extends StateMachine {
    private void doImmediateProvisioningFailure(int failureType) {
        logError("onProvisioningFailure(): %s", failureType);
        recordMetric(failureType);
        mCallback.onProvisioningFailure(new LinkProperties(mLinkProperties));
        mCallback.onProvisioningFailure(mLinkProperties);
    }

    private boolean startIPv4() {
@@ -1423,7 +1430,7 @@ public class IpClient extends StateMachine {
            if (mStartTimeMillis > 0) {
                // Completed a life-cycle; send a final empty LinkProperties
                // (cleared in resetLinkProperties() above) and record an event.
                mCallback.onLinkPropertiesChange(new LinkProperties(mLinkProperties));
                mCallback.onLinkPropertiesChange(mLinkProperties);
                recordMetric(IpManagerEvent.COMPLETE_LIFECYCLE);
                mStartTimeMillis = 0;
            }
@@ -1898,8 +1905,7 @@ public class IpClient extends StateMachine {
                        mDhcpClient.sendMessage(DhcpClient.EVENT_LINKADDRESS_CONFIGURED);
                    } else {
                        logError("Failed to set IPv4 address.");
                        dispatchCallback(PROV_CHANGE_LOST_PROVISIONING,
                                new LinkProperties(mLinkProperties));
                        dispatchCallback(PROV_CHANGE_LOST_PROVISIONING, mLinkProperties);
                        transitionTo(mStoppingState);
                    }
                    break;
+3 −1
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.internal.util.HexDump;
import com.android.networkstack.apishim.NetworkInformationShimImpl;
import com.android.server.networkstack.tests.R;
import com.android.server.util.NetworkStackConstants;

@@ -936,7 +937,8 @@ public class ApfTest {
        private byte[] mLastApfProgram;

        MockIpClientCallback() {
            super(mock(IIpClientCallbacks.class), mock(SharedLog.class));
            super(mock(IIpClientCallbacks.class), mock(SharedLog.class),
                    NetworkInformationShimImpl.newInstance());
        }

        @Override