diff options
3 files changed, 15 insertions, 23 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java index 378c116b4..d833cec34 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java @@ -32,7 +32,6 @@ import android.net.NetworkAgent; import android.net.NetworkAgentConfig; import android.net.NetworkCapabilities; import android.net.NetworkFactory; -import android.net.NetworkInfo; import android.net.NetworkProvider; import android.net.NetworkRequest; import android.net.NetworkSpecifier; @@ -557,8 +556,6 @@ public class WifiAwareDataPathStateManager { nnri.peerDataMac = mac; nnri.channelInfo = channelInfo; - NetworkInfo networkInfo = new NetworkInfo(ConnectivityManager.TYPE_NONE, 0, - NETWORK_TAG, ""); NetworkCapabilities networkCapabilities = new NetworkCapabilities( sNetworkCapabilitiesFilter); LinkProperties linkProperties = new LinkProperties(); @@ -638,7 +635,7 @@ public class WifiAwareDataPathStateManager { } if (!mNiWrapper.configureAgentProperties(nnri, nnri.equivalentRequests, ndpId, - networkInfo, networkCapabilities, linkProperties)) { + networkCapabilities, linkProperties)) { declareUnfullfillableAndEndDp(nnri, ndpId); return networkSpecifier; } @@ -653,8 +650,7 @@ public class WifiAwareDataPathStateManager { networkCapabilities, linkProperties, NETWORK_FACTORY_SCORE_AVAIL, naConfig, mNetworkFactory.getProvider(), nnri); nnri.startValidationTimestamp = mClock.getElapsedSinceBootMillis(); - handleAddressValidation(nnri, linkProperties, networkInfo, ndpId, - networkSpecifier.isOutOfBand()); + handleAddressValidation(nnri, linkProperties, ndpId, networkSpecifier.isOutOfBand()); } else { if (VDBG) { Log.v(TAG, "onDataPathConfirm: data-path for networkSpecifier=" + networkSpecifier @@ -670,10 +666,9 @@ public class WifiAwareDataPathStateManager { } private void handleAddressValidation(AwareNetworkRequestInformation nnri, - LinkProperties linkProperties, NetworkInfo networkInfo, int ndpId, - boolean isOutOfBand) { + LinkProperties linkProperties, int ndpId, boolean isOutOfBand) { if (mNiWrapper.isAddressUsable(linkProperties)) { - mNiWrapper.sendAgentNetworkInfo(nnri.networkAgent, networkInfo); + mNiWrapper.setConnected(nnri.networkAgent); mAwareMetrics.recordNdpStatus(NanStatusType.SUCCESS, isOutOfBand, nnri.startTimestamp); nnri.startTimestamp = mClock.getElapsedSinceBootMillis(); // update time-stamp @@ -690,7 +685,7 @@ public class WifiAwareDataPathStateManager { Log.d(TAG, "Failed address validation"); } mHandler.postDelayed(() -> { - handleAddressValidation(nnri, linkProperties, networkInfo, ndpId, isOutOfBand); + handleAddressValidation(nnri, linkProperties, ndpId, isOutOfBand); }, ADDRESS_VALIDATION_RETRY_INTERVAL_MS); } } @@ -1468,8 +1463,7 @@ public class WifiAwareDataPathStateManager { */ public boolean configureAgentProperties(AwareNetworkRequestInformation nnri, Set<NetworkRequest> networkRequests, int ndpId, - NetworkInfo networkInfo, NetworkCapabilities networkCapabilities, - LinkProperties linkProperties) { + NetworkCapabilities networkCapabilities, LinkProperties linkProperties) { // find link-local address InetAddress linkLocal = null; NetworkInterface ni; @@ -1505,9 +1499,6 @@ public class WifiAwareDataPathStateManager { return false; } - // configure agent - networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null); - networkCapabilities.setNetworkSpecifier(new WifiAwareAgentNetworkSpecifier( networkRequests.stream() .map(NetworkRequest::getNetworkSpecifier) @@ -1545,11 +1536,10 @@ public class WifiAwareDataPathStateManager { } /** - * Send updated network information to the agent. + * Tell the network agent the network is now connected. */ - public void sendAgentNetworkInfo(WifiAwareNetworkAgent networkAgent, - NetworkInfo networkInfo) { - networkAgent.sendNetworkInfo(networkInfo); + public void setConnected(WifiAwareNetworkAgent networkAgent) { + networkAgent.setConnected(); } } diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index d3c02c55c..b0cd6b9e9 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -411,7 +411,9 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { private NetworkInfo makeNetworkInfo() { final NetworkInfo info = new NetworkInfo(ConnectivityManager.TYPE_WIFI_P2P, 0, NETWORKTYPE, ""); - info.setDetailedState(mDetailedState, null, null); + if (mDetailedState != NetworkInfo.DetailedState.IDLE) { + info.setDetailedState(mDetailedState, null, null); + } return info; } diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java index e03805f8e..81efaf210 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java @@ -173,7 +173,7 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { mDut.startLate(); mMockLooper.dispatchAll(); - when(mMockNetworkInterface.configureAgentProperties(any(), any(), anyInt(), any(), any(), + when(mMockNetworkInterface.configureAgentProperties(any(), any(), anyInt(), any(), any())).thenReturn(true); when(mMockNetworkInterface.isAddressUsable(any())).thenReturn(true); @@ -1342,7 +1342,7 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { inOrder.verify(mMockNetdWrapper).setInterfaceUp(anyString()); inOrder.verify(mMockNetdWrapper).enableIpv6(anyString()); inOrder.verify(mMockNetworkInterface).configureAgentProperties(any(), any(), anyInt(), - any(), any(), any()); + any(), any()); inOrder.verify(mMockCm).registerNetworkAgent(messengerCaptor.capture(), any(), any(), netCapCaptor.capture(), anyInt(), any(), anyInt()); @@ -1372,7 +1372,7 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { inOrder.verify(mMockNative).endDataPath(transactionId.capture(), eq(ndpId)); mDut.onEndDataPathResponse(transactionId.getValue(), true, 0); } else { - inOrder.verify(mMockNetworkInterface).sendAgentNetworkInfo(any(), any()); + inOrder.verify(mMockNetworkInterface).setConnected(any()); inOrderM.verify(mAwareMetricsMock).recordNdpStatus(eq(NanStatusType.SUCCESS), eq(useDirect), anyLong()); inOrderM.verify(mAwareMetricsMock).recordNdpCreation(anyInt(), any()); |