diff options
author | James Mattis <jmattis@google.com> | 2022-02-26 22:16:46 -0800 |
---|---|---|
committer | James Mattis <jmattis@google.com> | 2022-03-07 13:45:52 -0800 |
commit | 9a47ae7fb8cfc56fa0ca89dbe95054855f81d5ea (patch) | |
tree | db9fc2b4e43361990f794dc07224dde62fe3fdca /java/com/android/server/ethernet/EthernetTracker.java | |
parent | b7c9537a271dca8917a0faf888afeaa5678770a1 (diff) | |
download | ethernet-9a47ae7fb8cfc56fa0ca89dbe95054855f81d5ea.tar.gz |
Eth Management APIs to Support TEST Interfaces
Updating Ethernet Network Management APIs to allow support for test
interfaces when the caller has the MANAGE_TEST_NETWORKS permission, test
interfaces are being tracked in ethernet and if updating a network's
capabilities, they include the TEST transport.
Bug: 210487893
Test: atest EthernetServiceTests
atest CtsNetTestCasesLatestSdk
:android.net.cts.EthernetManagerTest
Change-Id: I0e0bc9632d9b3d5d61f23e74150586f42c0b5bd2
Diffstat (limited to 'java/com/android/server/ethernet/EthernetTracker.java')
-rw-r--r-- | java/com/android/server/ethernet/EthernetTracker.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/java/com/android/server/ethernet/EthernetTracker.java b/java/com/android/server/ethernet/EthernetTracker.java index 794b5d1..9070a7e 100644 --- a/java/com/android/server/ethernet/EthernetTracker.java +++ b/java/com/android/server/ethernet/EthernetTracker.java @@ -86,6 +86,9 @@ public class EthernetTracker { * if setIncludeTestInterfaces is true, any test interfaces. */ private String mIfaceMatch; + /** + * Track test interfaces if true, don't track otherwise. + */ private boolean mIncludeTestInterfaces = false; /** Mapping between {iface name | mac address} -> {NetworkCapabilities} */ @@ -738,6 +741,17 @@ public class EthernetTracker { Log.d(TAG, "Interface match regexp set to '" + mIfaceMatch + "'"); } + /** + * Validate if a given interface is valid for testing. + * + * @param iface the name of the interface to validate. + * @return {@code true} if test interfaces are enabled and the given {@code iface} has a test + * interface prefix, {@code false} otherwise. + */ + public boolean isValidTestInterface(@NonNull final String iface) { + return mIncludeTestInterfaces && iface.matches(TEST_IFACE_REGEXP); + } + private void postAndWaitForRunnable(Runnable r) { final ConditionVariable cv = new ConditionVariable(); if (mHandler.post(() -> { |