summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/ServiceWifiResources/res/values/config.xml8
-rw-r--r--service/ServiceWifiResources/res/values/overlayable.xml1
-rw-r--r--service/java/com/android/server/wifi/HalDeviceManager.java31
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java131
4 files changed, 171 insertions, 0 deletions
diff --git a/service/ServiceWifiResources/res/values/config.xml b/service/ServiceWifiResources/res/values/config.xml
index ab73f3ac90..f85af51b18 100644
--- a/service/ServiceWifiResources/res/values/config.xml
+++ b/service/ServiceWifiResources/res/values/config.xml
@@ -1099,6 +1099,14 @@
it as low priority when disconnected, allowing it to be deleted to create other
interfaces. A negative value disables this behavior. -->
<integer translatable="false" name="config_disconnectedP2pIfaceLowPriorityTimeoutMs">-1</integer>
+ <!-- list of package names that the framework will allow to use P2P/Aware concurrency. If this
+ list is empty, then all packages are allowed -->
+ <string-array translatable="false" name="config_wifiP2pAwareConcurrencyAllowlist">
+ <!-- Below is a sample configuration for this list:
+ <item>com.company1.example.test.name1</item>
+ <item>com.company2.example.test.name2</item>
+ -->
+ </string-array>
<!-- boolean indicating whether the Easy Connect (DPP) AKM is supported -->
<bool translatable="false" name ="config_wifiDppAkmSupported">false</bool>
<!-- Indicates the number of octets to mask for each BSSID in the SecurityLog output.
diff --git a/service/ServiceWifiResources/res/values/overlayable.xml b/service/ServiceWifiResources/res/values/overlayable.xml
index e736668dd1..3b8333a1c7 100644
--- a/service/ServiceWifiResources/res/values/overlayable.xml
+++ b/service/ServiceWifiResources/res/values/overlayable.xml
@@ -305,6 +305,7 @@
<item type="array" name="config_wifiExcludedFromUserApprovalForD2dInterfacePriority" />
<item type="bool" name="config_wifiUserApprovalNotRequireForDisconnectedP2p" />
<item type="integer" name="config_disconnectedP2pIfaceLowPriorityTimeoutMs" />
+ <item type="array" name="config_wifiP2pAwareConcurrencyAllowlist" />
<item type="bool" name="config_wifiNetworkCentricQosPolicyFeatureEnabled" />
<item type="bool" name="config_wifiApplicationCentricQosPolicyFeatureEnabled" />
<item type="string" name="config_wifiDriverWorldModeCountryCode" />
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index 99f929c8f3..0959c31c1c 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -1851,6 +1851,22 @@ public class HalDeviceManager {
}
}
+ private boolean isRequestorAllowedToUseP2pNanConcurrency(WorkSource requestorWs) {
+ String[] allowlistArray = mContext.getResources().getStringArray(
+ R.array.config_wifiP2pAwareConcurrencyAllowlist);
+ if (allowlistArray == null || allowlistArray.length == 0) {
+ // No allowlist defined, so allow.
+ return true;
+ }
+ List<String> allowlist = Arrays.asList(allowlistArray);
+ for (int i = 0; i < requestorWs.size(); i++) {
+ if (allowlist.contains(requestorWs.getPackageName(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Checks whether the input chip-create-type-combo can support the requested create type:
* if not then returns null, if yes then returns information containing the list of interfaces
@@ -1883,6 +1899,21 @@ public class HalDeviceManager {
return null;
}
+ // Remove P2P/NAN concurrency if the requestor isn't on the allowlist.
+ if ((requestedCreateType == HDM_CREATE_IFACE_P2P
+ || requestedCreateType == HDM_CREATE_IFACE_NAN)
+ && chipCreateTypeCombo[HDM_CREATE_IFACE_P2P] > 0
+ && chipCreateTypeCombo[HDM_CREATE_IFACE_NAN] > 0) {
+ if (!isRequestorAllowedToUseP2pNanConcurrency(requestorWs)) {
+ chipCreateTypeCombo = chipCreateTypeCombo.clone();
+ if (requestedCreateType == HDM_CREATE_IFACE_P2P) {
+ chipCreateTypeCombo[HDM_CREATE_IFACE_NAN] = 0;
+ } else {
+ chipCreateTypeCombo[HDM_CREATE_IFACE_P2P] = 0;
+ }
+ }
+ }
+
IfaceCreationData ifaceCreationData = new IfaceCreationData();
ifaceCreationData.chipInfo = chipInfo;
ifaceCreationData.chipModeId = chipModeId;
diff --git a/service/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java
index 36e54b0680..781ea3b255 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java
@@ -3987,6 +3987,104 @@ public class HalDeviceManagerTest extends WifiBaseTest {
);
}
+ /**
+ * Validate a P2P request from requestors not on the P2P/NAN concurrency allowlist.
+ */
+ @Test
+ public void testP2pNanConcurrencyNotAllowedTestChipV11()
+ throws Exception {
+ when(mResources.getStringArray(R.array.config_wifiP2pAwareConcurrencyAllowlist)).thenReturn(
+ new String[]{"Some other package"});
+
+ TestChipV11 chipMock = new TestChipV11();
+ chipMock.initialize();
+ mInOrder = inOrder(mWifiMock, chipMock.chip, mManagerStatusListenerMock);
+ executeAndValidateStartupSequence();
+
+ InterfaceDestroyedListener idl = mock(InterfaceDestroyedListener.class);
+
+ // Create a NAN
+ WifiInterface nanIface = validateInterfaceSequence(chipMock,
+ false, // chipModeValid
+ -1000, // chipModeId (only used if chipModeValid is true)
+ HDM_CREATE_IFACE_NAN,
+ "wlan0",
+ TestChipV11.CHIP_MODE_ID,
+ null, // tearDownList
+ idl, // destroyedListener
+ TEST_WORKSOURCE_0 // requestorWs
+ );
+ collector.checkThat("interface was null", nanIface, IsNull.notNullValue());
+
+ // P2P request from Worksource 1 (lower priority) should be blocked.
+ when(mWorkSourceHelper1.getRequestorWsPriority())
+ .thenReturn(WorkSourceHelper.PRIORITY_FG_APP);
+ List<Pair<Integer, WorkSource>> p2pDetails = mDut.reportImpactToCreateIface(
+ HDM_CREATE_IFACE_P2P, true, TEST_WORKSOURCE_1);
+ if (SdkLevel.isAtLeastS()) {
+ assertNull("Should not be able to create this P2P", p2pDetails);
+ } else {
+ // Pre-S lets P2P/NAN destroy each other.
+ assertEquals(p2pDetails.get(0).second, TEST_WORKSOURCE_0);
+ }
+
+ // P2P request from Worksource 2 (same privileged priority) should tear down NAN.
+ WifiInterface p2pIface = validateInterfaceSequence(chipMock,
+ true, // chipModeValid
+ TestChipV11.CHIP_MODE_ID, // chipModeId (only used if chipModeValid is true)
+ HDM_CREATE_IFACE_P2P,
+ "wlan1",
+ TestChipV11.CHIP_MODE_ID,
+ new WifiInterface[]{nanIface}, // tearDownList
+ idl, // destroyedListener
+ TEST_WORKSOURCE_2 // requestorWs
+ );
+ collector.checkThat("interface was null", p2pIface, IsNull.notNullValue());
+ }
+
+ /**
+ * Validate a P2P request from a requestor on the P2P/NAN concurrency allowlist.
+ */
+ @Test
+ public void testP2pNanConcurrencyAllowedTestChipV11()
+ throws Exception {
+ when(mResources.getStringArray(R.array.config_wifiP2pAwareConcurrencyAllowlist)).thenReturn(
+ new String[]{TEST_WORKSOURCE_1.getPackageName(0)});
+
+ TestChipV11 chipMock = new TestChipV11();
+ chipMock.initialize();
+ mInOrder = inOrder(mWifiMock, chipMock.chip, mManagerStatusListenerMock);
+ executeAndValidateStartupSequence();
+
+ InterfaceDestroyedListener idl = mock(InterfaceDestroyedListener.class);
+
+ // Create a NAN
+ WifiInterface nanIface = validateInterfaceSequence(chipMock,
+ false, // chipModeValid
+ -1000, // chipModeId (only used if chipModeValid is true)
+ HDM_CREATE_IFACE_NAN,
+ "wlan0",
+ TestChipV11.CHIP_MODE_ID,
+ null, // tearDownList
+ idl, // destroyedListener
+ TEST_WORKSOURCE_0 // requestorWs
+ );
+ collector.checkThat("interface was null", nanIface, IsNull.notNullValue());
+
+ // P2P request from Worksource 1 (on allowlist) should be allowed.
+ WifiInterface p2pIface = validateInterfaceSequence(chipMock,
+ true, // chipModeValid
+ TestChipV11.CHIP_MODE_ID, // chipModeId (only used if chipModeValid is true)
+ HDM_CREATE_IFACE_P2P,
+ "wlan1",
+ TestChipV11.CHIP_MODE_ID,
+ null, // tearDownList
+ idl, // destroyedListener
+ TEST_WORKSOURCE_1 // requestorWs
+ );
+ collector.checkThat("interface was null", p2pIface, IsNull.notNullValue());
+ }
+
///////////////////////////////////////////////////////////////////////////////////////
// utilities
///////////////////////////////////////////////////////////////////////////////////////
@@ -5285,4 +5383,37 @@ public class HalDeviceManagerTest extends WifiBaseTest {
configureDriverAvailableModes();
}
}
+
+ // Test chip configuration V11 for P2P/NAN concurrency
+ // mode:
+ // (STA + AP + NAN + P2P)
+ private class TestChipV11 extends ChipMockBase {
+ static final int CHIP_MODE_ID = 90;
+
+ void initialize() throws Exception {
+ super.initialize();
+
+ // chip Id configuration
+ ArrayList<Integer> chipIds;
+ chipId = 11;
+ chipIds = new ArrayList<>();
+ chipIds.add(chipId);
+ doAnswer(new GetChipIdsAnswer(true, chipIds)).when(mWifiMock).getChipIds();
+ doAnswer(new GetChipAnswer(true, chip)).when(mWifiMock).getChip(anyInt());
+
+ // Initialize availableModes
+ availableModes = new ArrayList<>();
+
+ // Mode 90 (only one): (1xSTA + 1xAP + 1xP2P + 1xNAN)
+ WifiChip.ChipConcurrencyCombination combo1 = createConcurrencyCombo(
+ createConcurrencyComboLimit(1, WifiChip.IFACE_CONCURRENCY_TYPE_STA),
+ createConcurrencyComboLimit(1, WifiChip.IFACE_CONCURRENCY_TYPE_AP),
+ createConcurrencyComboLimit(1, WifiChip.IFACE_CONCURRENCY_TYPE_P2P),
+ createConcurrencyComboLimit(1, WifiChip.IFACE_CONCURRENCY_TYPE_NAN));
+ availableModes.add(createChipMode(CHIP_MODE_ID, combo1));
+
+ chipModeIdValidForRtt = CHIP_MODE_ID;
+ doAnswer(new GetAvailableModesAnswer(this)).when(chip).getAvailableModes();
+ }
+ }
}