Snap for 8012283 from 083c5c432d4dc0d7e126cf06860c640a7fa2664c to s-keystone-qcom-release

Change-Id: I30fbc4b492b8a129f5c021945e416bf297f41d1c
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java
index d429643..a57e99d 100644
--- a/src/android/net/ip/IpClient.java
+++ b/src/android/net/ip/IpClient.java
@@ -1961,9 +1961,6 @@
             if (mDhcpClient == null) {
                 // There's no DHCPv4 for which to wait; proceed to stopped.
                 deferMessage(obtainMessage(CMD_JUMP_STOPPING_TO_STOPPED));
-            } else {
-                mDhcpClient.sendMessage(DhcpClient.CMD_STOP_DHCP);
-                mDhcpClient.doQuit();
             }
 
             // Restore the interface MTU to initial value if it has changed.
@@ -2269,6 +2266,11 @@
                 mIpReachabilityMonitor = null;
             }
 
+            if (mDhcpClient != null) {
+                mDhcpClient.sendMessage(DhcpClient.CMD_STOP_DHCP);
+                mDhcpClient.doQuit();
+            }
+
             if (mPacketTracker != null) {
                 mPacketTracker.stop();
                 mPacketTracker = null;
diff --git a/tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java b/tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java
index 7b35636..c121b3d 100644
--- a/tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java
+++ b/tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java
@@ -2000,52 +2000,6 @@
     }
 
     @Test
-    @SignatureRequiredTest(reason = "needs mocked alarm and access to IpClient handler thread")
-    public void testDhcpClientPreconnection_DelayedAbortAndTransitToStoppedState()
-            throws Exception {
-        ProvisioningConfiguration config = new ProvisioningConfiguration.Builder()
-                .withoutIpReachabilityMonitor()
-                .withPreconnection()
-                .build();
-        setDhcpFeatures(false /* isDhcpLeaseCacheEnabled */, false /* shouldReplyRapidCommitAck */,
-                false /* isDhcpIpConflictDetectEnabled */, false /* isIPv6OnlyPreferredEnabled */);
-        startIpClientProvisioning(config);
-        assertDiscoverPacketOnPreconnectionStart();
-
-        // IpClient is in the PreconnectingState, simulate provisioning timeout event
-        // and force IpClient state machine transit to StoppingState.
-        final ArgumentCaptor<LinkProperties> captor = ArgumentCaptor.forClass(LinkProperties.class);
-        final OnAlarmListener alarm = expectAlarmSet(null /* inOrder */, "TIMEOUT", 18,
-                mIpc.getHandler());
-        mIpc.getHandler().post(() -> alarm.onAlarm());
-
-        verify(mCb, timeout(TEST_TIMEOUT_MS)).onProvisioningFailure(captor.capture());
-        final LinkProperties lp = captor.getValue();
-        assertNotNull(lp);
-        assertEquals(mIfaceName, lp.getInterfaceName());
-        assertEquals(0, lp.getLinkAddresses().size());
-        assertEquals(0, lp.getRoutes().size());
-        assertEquals(0, lp.getMtu());
-        assertEquals(0, lp.getDnsServers().size());
-
-        // Send preconnection abort message, but IpClient should ignore it at this moment and
-        // transit to StoppedState finally.
-        mIpc.notifyPreconnectionComplete(false /* abort */);
-        mIpc.stop();
-        HandlerUtils.waitForIdle(mIpc.getHandler(), TEST_TIMEOUT_MS);
-
-        reset(mCb);
-
-        // Start provisioning again to verify IpClient can process CMD_START correctly at
-        // StoppedState.
-        startIpClientProvisioning(false /* isDhcpLeaseCacheEnabled */,
-                false /* shouldReplyRapidCommitAck */, false /* isPreConnectionEnabled */,
-                false /* isDhcpIpConflictDetectEnabled */, false /* isIPv6OnlyPreferredEnabled */);
-        final DhcpPacket discover = getNextDhcpPacket();
-        assertTrue(discover instanceof DhcpDiscoverPacket);
-    }
-
-    @Test
     public void testDhcpDecline_conflictByArpReply() throws Exception {
         doIpAddressConflictDetectionTest(true /* causeIpAddressConflict */,
                 false /* shouldReplyRapidCommitAck */, true /* isDhcpIpConflictDetectEnabled */,