diff options
author | Etan Cohen <etancohen@google.com> | 2017-05-10 13:28:17 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-10 13:28:25 +0000 |
commit | acfa5dbe0fc7684c6e80316bd07d293e6cc367c4 (patch) | |
tree | 169b5e42fefbade562b74605da0ab89ca471c8c5 | |
parent | ca614a7314230e93a69110c94e7ea2d38b3f87a1 (diff) | |
parent | ff05cbcaccc03d1f64d1cb232a3c40a664c4be57 (diff) |
Merge "[AWARE] Add a fixed service-name for OOB passphrase-protected data-path"
4 files changed, 24 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java index 723828d7f..0535512fe 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java @@ -639,7 +639,7 @@ public class WifiAwareDataPathStateManager { mMgr.initiateDataPathSetup(networkSpecifier, nnri.networkSpecifier.peerId, NanDataPathChannelCfg.REQUEST_CHANNEL_SETUP, selectChannelForRequest(nnri), nnri.peerDiscoveryMac, nnri.interfaceName, nnri.networkSpecifier.pmk, - nnri.networkSpecifier.passphrase); + nnri.networkSpecifier.passphrase, nnri.networkSpecifier.isOutOfBand()); nnri.state = AwareNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE; } else { diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java index 2efa2aecc..9395e6a5d 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java @@ -42,6 +42,7 @@ import libcore.util.HexEncoding; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; /** @@ -54,6 +55,8 @@ public class WifiAwareNativeApi { private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true + private static final String SERVICE_NAME_FOR_OOB_DATA_PATH = "Wi-Fi Aware Data Path"; + private final WifiAwareNativeManager mHal; public WifiAwareNativeApi(WifiAwareNativeManager wifiAwareNativeManager) { @@ -605,7 +608,7 @@ public class WifiAwareNativeApi { */ public boolean initiateDataPath(short transactionId, int peerId, int channelRequestType, int channel, byte[] peer, String interfaceName, byte[] pmk, String passphrase, - Capabilities capabilities) { + boolean isOutOfBand, Capabilities capabilities) { if (VDBG) { Log.v(TAG, "initiateDataPath: transactionId=" + transactionId + ", peerId=" + peerId + ", channelRequestType=" + channelRequestType + ", channel=" + channel @@ -642,6 +645,12 @@ public class WifiAwareNativeApi { capabilities.supportedCipherSuites); req.securityConfig.securityType = NanDataPathSecurityType.PASSPHRASE; convertNativeByteArrayToArrayList(passphrase.getBytes(), req.securityConfig.passphrase); + + if (isOutOfBand) { // only relevant when using passphrase + convertNativeByteArrayToArrayList( + SERVICE_NAME_FOR_OOB_DATA_PATH.getBytes(StandardCharsets.UTF_8), + req.serviceNameOutOfBand); + } } try { diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java index a35c786ee..9c4fb4623 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java @@ -171,6 +171,7 @@ public class WifiAwareStateManager { private static final String MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE = "notify_identity_chg"; private static final String MESSAGE_BUNDLE_KEY_PMK = "pmk"; private static final String MESSAGE_BUNDLE_KEY_PASSPHRASE = "passphrase"; + private static final String MESSAGE_BUNDLE_KEY_OOB = "out_of_band"; private WifiAwareNativeApi mWifiAwareNativeApi; @@ -468,7 +469,7 @@ public class WifiAwareStateManager { */ public void initiateDataPathSetup(WifiAwareNetworkSpecifier networkSpecifier, int peerId, int channelRequestType, int channel, byte[] peer, String interfaceName, byte[] pmk, - String passphrase) { + String passphrase, boolean isOutOfBand) { Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND); msg.arg1 = COMMAND_TYPE_INITIATE_DATA_PATH_SETUP; msg.obj = networkSpecifier; @@ -479,6 +480,7 @@ public class WifiAwareStateManager { msg.getData().putString(MESSAGE_BUNDLE_KEY_INTERFACE_NAME, interfaceName); msg.getData().putByteArray(MESSAGE_BUNDLE_KEY_PMK, pmk); msg.getData().putString(MESSAGE_BUNDLE_KEY_PASSPHRASE, passphrase); + msg.getData().putBoolean(MESSAGE_BUNDLE_KEY_OOB, isOutOfBand); mSm.sendMessage(msg); } @@ -1377,10 +1379,11 @@ public class WifiAwareStateManager { String interfaceName = data.getString(MESSAGE_BUNDLE_KEY_INTERFACE_NAME); byte[] pmk = data.getByteArray(MESSAGE_BUNDLE_KEY_PMK); String passphrase = data.getString(MESSAGE_BUNDLE_KEY_PASSPHRASE); + boolean isOutOfBand = data.getBoolean(MESSAGE_BUNDLE_KEY_OOB); waitForResponse = initiateDataPathSetupLocal(mCurrentTransactionId, networkSpecifier, peerId, channelRequestType, channel, peer, - interfaceName, pmk, passphrase); + interfaceName, pmk, passphrase, isOutOfBand); if (waitForResponse) { WakeupMessage timeout = new WakeupMessage(mContext, getHandler(), @@ -2074,7 +2077,8 @@ public class WifiAwareStateManager { private boolean initiateDataPathSetupLocal(short transactionId, WifiAwareNetworkSpecifier networkSpecifier, int peerId, int channelRequestType, - int channel, byte[] peer, String interfaceName, byte[] pmk, String passphrase) { + int channel, byte[] peer, String interfaceName, byte[] pmk, String passphrase, + boolean isOutOfBand) { if (VDBG) { Log.v(TAG, "initiateDataPathSetupLocal(): transactionId=" + transactionId @@ -2082,11 +2086,12 @@ public class WifiAwareStateManager { + ", channelRequestType=" + channelRequestType + ", channel=" + channel + ", peer=" + String.valueOf(HexEncoding.encode(peer)) + ", interfaceName=" + interfaceName + ", pmk=" + pmk - + ", passphrase=" + passphrase); + + ", passphrase=" + passphrase + ", isOutOfBand=" + isOutOfBand); } boolean success = mWifiAwareNativeApi.initiateDataPath(transactionId, peerId, - channelRequestType, channel, peer, interfaceName, pmk, passphrase, mCapabilities); + channelRequestType, channel, peer, interfaceName, pmk, passphrase, isOutOfBand, + mCapabilities); if (!success) { mDataPathMgr.onDataPathInitiateFail(networkSpecifier, NanStatusType.INTERNAL_FAILURE); } 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 a2e7c77cf..8835d75b8 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java @@ -136,7 +136,7 @@ public class WifiAwareDataPathStateManagerTest { when(mMockNative.createAwareNetworkInterface(anyShort(), any())).thenReturn(true); when(mMockNative.deleteAwareNetworkInterface(anyShort(), any())).thenReturn(true); when(mMockNative.initiateDataPath(anyShort(), anyInt(), anyInt(), anyInt(), - any(), any(), any(), any(), + any(), any(), any(), any(), anyBoolean(), any())).thenReturn(true); when(mMockNative.respondToDataPathRequest(anyShort(), anyBoolean(), anyInt(), any(), any(), any(), any())).thenReturn(true); @@ -562,7 +562,7 @@ public class WifiAwareDataPathStateManagerTest { if (immediateHalFailure) { when(mMockNative.initiateDataPath(anyShort(), anyInt(), anyInt(), anyInt(), any(), - any(), any(), any(), any())).thenReturn(false); + any(), any(), any(), anyBoolean(), any())).thenReturn(false); } @@ -590,7 +590,7 @@ public class WifiAwareDataPathStateManagerTest { inOrder.verify(mMockNative).initiateDataPath(transactionId.capture(), eq(useDirect ? 0 : peerHandle.peerId), eq(REQUEST_CHANNEL_SETUP), eq(2437), eq(peerDiscoveryMac), - eq(sAwareInterfacePrefix + "0"), eq(pmk), eq(null), any()); + eq(sAwareInterfacePrefix + "0"), eq(pmk), eq(null), eq(useDirect), any()); if (immediateHalFailure) { // short-circuit the rest of this test verifyNoMoreInteractions(mMockNative, mMockCm); |