Merge "Add setFirewallChainEnabled API"

This commit is contained in:
Mark Chien
2022-01-14 05:33:38 +00:00
committed by Gerrit Code Review
4 changed files with 37 additions and 0 deletions

View File

@@ -5674,4 +5674,26 @@ public class ConnectivityManager {
throw e.rethrowFromSystemServer();
}
}
/**
* Enables or disables the specified firewall chain.
*
* @param chain target chain.
* @param enable whether the chain should be enabled.
* @throws IllegalStateException if set firewall chain failed.
* @hide
*/
@SystemApi(client = MODULE_LIBRARIES)
@RequiresPermission(anyOf = {
android.Manifest.permission.NETWORK_SETTINGS,
android.Manifest.permission.NETWORK_STACK,
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK
})
public void setFirewallChainEnabled(@FirewallChain final int chain, final boolean enable) {
try {
mService.setFirewallChainEnabled(chain, enable);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}

View File

@@ -236,4 +236,6 @@ interface IConnectivityManager
void updateMeteredNetworkDenyList(int uid, boolean add);
void updateFirewallRule(int chain, int uid, boolean allow);
void setFirewallChainEnabled(int chain, boolean enable);
}