Add API to get current firewall chain status

This commit adds ConnectivityManager#getFirewallChainEnabled to read the
current firewall chain status

Bug: 208371987
Test: m
Change-Id: I1eadb69f953af5d031cd8dabde3e1f098cf0f4df
This commit is contained in:
Motomu Utsumi
2022-06-08 10:05:07 +00:00
parent 1c52aa12e8
commit be3ff1e923
6 changed files with 281 additions and 2 deletions

View File

@@ -5920,6 +5920,30 @@ public class ConnectivityManager {
}
}
/**
* Get the specified firewall chain status.
*
* @param chain target chain.
* @return {@code true} if chain is enabled, {@code false} if chain is disabled.
* @throws UnsupportedOperationException if called on pre-T devices.
* @throws IllegalArgumentException if {@code chain} is a invalid value.
* @throws ServiceSpecificException in case of failure, with an error code indicating the
* cause of the failure.
* @hide
*/
@RequiresPermission(anyOf = {
android.Manifest.permission.NETWORK_SETTINGS,
android.Manifest.permission.NETWORK_STACK,
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK
})
public boolean getFirewallChainEnabled(@FirewallChain final int chain) {
try {
return mService.getFirewallChainEnabled(chain);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Replaces the contents of the specified UID-based firewall chain.
*