Merge "Make ThreadNetworkController.setTestNetworkAsUpstream require NETWORK_SETTINGS permission" into main
This commit is contained in:
commit
ba2480bb2e
4 changed files with 40 additions and 34 deletions
|
|
@ -510,7 +510,8 @@ public final class ThreadNetworkController {
|
|||
* @hide
|
||||
*/
|
||||
@VisibleForTesting
|
||||
@RequiresPermission("android.permission.THREAD_NETWORK_PRIVILEGED")
|
||||
@RequiresPermission(
|
||||
allOf = {"android.permission.THREAD_NETWORK_PRIVILEGED", permission.NETWORK_SETTINGS})
|
||||
public void setTestNetworkAsUpstream(
|
||||
@Nullable String testNetworkInterfaceName,
|
||||
@NonNull @CallbackExecutor Executor executor,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package com.android.server.thread;
|
||||
|
||||
import static android.Manifest.permission.NETWORK_SETTINGS;
|
||||
import static android.net.MulticastRoutingConfig.CONFIG_FORWARD_NONE;
|
||||
import static android.net.MulticastRoutingConfig.FORWARD_NONE;
|
||||
import static android.net.MulticastRoutingConfig.FORWARD_SELECTED;
|
||||
|
|
@ -253,38 +254,6 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub
|
|||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTestNetworkAsUpstream(
|
||||
@Nullable String testNetworkInterfaceName, @NonNull IOperationReceiver receiver) {
|
||||
enforceAllPermissionsGranted(PERMISSION_THREAD_NETWORK_PRIVILEGED);
|
||||
|
||||
Log.i(TAG, "setTestNetworkAsUpstream: " + testNetworkInterfaceName);
|
||||
mHandler.post(() -> setTestNetworkAsUpstreamInternal(testNetworkInterfaceName, receiver));
|
||||
}
|
||||
|
||||
private void setTestNetworkAsUpstreamInternal(
|
||||
@Nullable String testNetworkInterfaceName, @NonNull IOperationReceiver receiver) {
|
||||
checkOnHandlerThread();
|
||||
|
||||
TestNetworkSpecifier testNetworkSpecifier = null;
|
||||
if (testNetworkInterfaceName != null) {
|
||||
testNetworkSpecifier = new TestNetworkSpecifier(testNetworkInterfaceName);
|
||||
}
|
||||
|
||||
if (!Objects.equals(mUpstreamTestNetworkSpecifier, testNetworkSpecifier)) {
|
||||
cancelRequestUpstreamNetwork();
|
||||
mUpstreamTestNetworkSpecifier = testNetworkSpecifier;
|
||||
mUpstreamNetworkRequest = newUpstreamNetworkRequest();
|
||||
requestUpstreamNetwork();
|
||||
sendLocalNetworkConfig();
|
||||
}
|
||||
try {
|
||||
receiver.onSuccess();
|
||||
} catch (RemoteException ignored) {
|
||||
// do nothing if the client is dead
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeOtDaemon() {
|
||||
try {
|
||||
getOtDaemon();
|
||||
|
|
@ -786,6 +755,38 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTestNetworkAsUpstream(
|
||||
@Nullable String testNetworkInterfaceName, @NonNull IOperationReceiver receiver) {
|
||||
enforceAllPermissionsGranted(PERMISSION_THREAD_NETWORK_PRIVILEGED, NETWORK_SETTINGS);
|
||||
|
||||
Log.i(TAG, "setTestNetworkAsUpstream: " + testNetworkInterfaceName);
|
||||
mHandler.post(() -> setTestNetworkAsUpstreamInternal(testNetworkInterfaceName, receiver));
|
||||
}
|
||||
|
||||
private void setTestNetworkAsUpstreamInternal(
|
||||
@Nullable String testNetworkInterfaceName, @NonNull IOperationReceiver receiver) {
|
||||
checkOnHandlerThread();
|
||||
|
||||
TestNetworkSpecifier testNetworkSpecifier = null;
|
||||
if (testNetworkInterfaceName != null) {
|
||||
testNetworkSpecifier = new TestNetworkSpecifier(testNetworkInterfaceName);
|
||||
}
|
||||
|
||||
if (!Objects.equals(mUpstreamTestNetworkSpecifier, testNetworkSpecifier)) {
|
||||
cancelRequestUpstreamNetwork();
|
||||
mUpstreamTestNetworkSpecifier = testNetworkSpecifier;
|
||||
mUpstreamNetworkRequest = newUpstreamNetworkRequest();
|
||||
requestUpstreamNetwork();
|
||||
sendLocalNetworkConfig();
|
||||
}
|
||||
try {
|
||||
receiver.onSuccess();
|
||||
} catch (RemoteException ignored) {
|
||||
// do nothing if the client is dead
|
||||
}
|
||||
}
|
||||
|
||||
private void enableBorderRouting(String infraIfName) {
|
||||
if (mBorderRouterConfig.isBorderRoutingEnabled
|
||||
&& infraIfName.equals(mBorderRouterConfig.infraInterfaceName)) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
obtain CHANGE_NETWORK_STATE for testing once R device is no longer supported. -->
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.THREAD_NETWORK_PRIVILEGED"/>
|
||||
<uses-permission android:name="android.permission.NETWORK_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application android:debuggable="true">
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package android.net.thread;
|
||||
|
||||
import static android.Manifest.permission.MANAGE_TEST_NETWORKS;
|
||||
import static android.Manifest.permission.NETWORK_SETTINGS;
|
||||
import static android.net.thread.IntegrationTestUtils.isExpectedIcmpv6Packet;
|
||||
import static android.net.thread.IntegrationTestUtils.isSimulatedThreadRadioSupported;
|
||||
import static android.net.thread.IntegrationTestUtils.newPacketReader;
|
||||
|
|
@ -101,6 +102,7 @@ public class BorderRoutingTest {
|
|||
mContext, new LinkProperties(), 5000 /* timeoutMs */));
|
||||
runAsShell(
|
||||
PERMISSION_THREAD_NETWORK_PRIVILEGED,
|
||||
NETWORK_SETTINGS,
|
||||
() -> {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
mThreadNetworkController.setTestNetworkAsUpstream(
|
||||
|
|
@ -117,6 +119,7 @@ public class BorderRoutingTest {
|
|||
public void tearDown() throws Exception {
|
||||
runAsShell(
|
||||
PERMISSION_THREAD_NETWORK_PRIVILEGED,
|
||||
NETWORK_SETTINGS,
|
||||
() -> {
|
||||
CountDownLatch latch = new CountDownLatch(2);
|
||||
mThreadNetworkController.setTestNetworkAsUpstream(
|
||||
|
|
@ -132,7 +135,7 @@ public class BorderRoutingTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void infraDevicePingTheadDeviceOmr_Succeeds() throws Exception {
|
||||
public void unicastRouting_infraDevicePingTheadDeviceOmr_replyReceived() throws Exception {
|
||||
assumeTrue(isSimulatedThreadRadioSupported());
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue