From 340c5ca5141971deb6772aca0e6d004122fe90f1 Mon Sep 17 00:00:00 2001 From: Kangping Dong Date: Fri, 21 Mar 2025 17:07:26 +0800 Subject: [PATCH] [Thread] grant the NEARBY_WIFI_DEVICES permission to Thread tests Fix forward for b/405297285 Background: new / existing runtime permission is now used to guard access to local networks. apps / tests now need to hold this permission to do traffic with local devices. Test: atest ThreadNetworkIntegrationTests Bug: 405297285 Change-Id: I31aaf147a9f9bd8fab7640b935a163405d31e2b9 --- thread/tests/integration/AndroidManifest.xml | 1 + .../src/android/net/thread/ThreadIntegrationTest.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/thread/tests/integration/AndroidManifest.xml b/thread/tests/integration/AndroidManifest.xml index a049184d6d..8bee1e1da3 100644 --- a/thread/tests/integration/AndroidManifest.xml +++ b/thread/tests/integration/AndroidManifest.xml @@ -24,6 +24,7 @@ + diff --git a/thread/tests/integration/src/android/net/thread/ThreadIntegrationTest.java b/thread/tests/integration/src/android/net/thread/ThreadIntegrationTest.java index b608c5d9c2..70f17ffce8 100644 --- a/thread/tests/integration/src/android/net/thread/ThreadIntegrationTest.java +++ b/thread/tests/integration/src/android/net/thread/ThreadIntegrationTest.java @@ -27,6 +27,8 @@ import static android.net.thread.utils.IntegrationTestUtils.waitFor; import static android.net.thread.utils.ThreadNetworkControllerWrapper.JOIN_TIMEOUT; import static android.os.SystemClock.elapsedRealtime; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; + import static com.android.compatibility.common.util.SystemUtil.runShellCommand; import static com.android.compatibility.common.util.SystemUtil.runShellCommandOrThrow; import static com.android.testutils.TestPermissionUtil.runAsShell; @@ -121,6 +123,12 @@ public class ThreadIntegrationTest { @Before public void setUp() throws Exception { + getInstrumentation() + .getUiAutomation() + .grantRuntimePermission( + "com.android.thread.tests.integration", + "android.permission.NEARBY_WIFI_DEVICES"); + mExecutor = Executors.newSingleThreadExecutor(); mFtd = new FullThreadDevice(10 /* nodeId */); mOtCtl = new OtDaemonController();