Merge "Update NPMS to inform NMS of the changes in fw rules synchronously." into oc-mr1-dev am: 7a349d7288

am: 99ae0aed0d

Change-Id: If264a7fc7e0300961d8f76c37c74ef2f4ae51088
This commit is contained in:
Sudheer Shanka
2017-10-04 07:14:58 +00:00
committed by android-build-merger

View File

@@ -331,7 +331,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private static final int MSG_UPDATE_INTERFACE_QUOTA = 10;
private static final int MSG_REMOVE_INTERFACE_QUOTA = 11;
private static final int MSG_POLICIES_CHANGED = 13;
private static final int MSG_SET_FIREWALL_RULES = 14;
private static final int MSG_RESET_FIREWALL_RULES_BY_UID = 15;
private static final int UID_MSG_STATE_CHANGED = 100;
@@ -3138,9 +3137,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
uidRules.put(mUidState.keyAt(i), FIREWALL_RULE_ALLOW);
}
}
setUidFirewallRulesAsync(chain, uidRules, CHAIN_TOGGLE_ENABLE);
setUidFirewallRulesUL(chain, uidRules, CHAIN_TOGGLE_ENABLE);
} else {
setUidFirewallRulesAsync(chain, null, CHAIN_TOGGLE_DISABLE);
setUidFirewallRulesUL(chain, null, CHAIN_TOGGLE_DISABLE);
}
}
@@ -3207,7 +3206,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
}
setUidFirewallRulesAsync(FIREWALL_CHAIN_STANDBY, uidRules, CHAIN_TOGGLE_NONE);
setUidFirewallRulesUL(FIREWALL_CHAIN_STANDBY, uidRules, CHAIN_TOGGLE_NONE);
} finally {
Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
}
@@ -3906,18 +3905,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
removeInterfaceQuota((String) msg.obj);
return true;
}
case MSG_SET_FIREWALL_RULES: {
final int chain = msg.arg1;
final int toggle = msg.arg2;
final SparseIntArray uidRules = (SparseIntArray) msg.obj;
if (uidRules != null) {
setUidFirewallRules(chain, uidRules);
}
if (toggle != CHAIN_TOGGLE_NONE) {
enableFirewallChainUL(chain, toggle == CHAIN_TOGGLE_ENABLE);
}
return true;
}
case MSG_RESET_FIREWALL_RULES_BY_UID: {
resetUidFirewallRules(msg.arg1);
return true;
@@ -4063,15 +4050,20 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
/**
* Calls {@link #setUidFirewallRules(int, SparseIntArray)} and
* {@link #enableFirewallChainUL(int, boolean)} asynchronously.
* {@link #enableFirewallChainUL(int, boolean)} synchronously.
*
* @param chain firewall chain.
* @param uidRules new UID rules; if {@code null}, only toggles chain state.
* @param toggle whether the chain should be enabled, disabled, or not changed.
*/
private void setUidFirewallRulesAsync(int chain, @Nullable SparseIntArray uidRules,
private void setUidFirewallRulesUL(int chain, @Nullable SparseIntArray uidRules,
@ChainToggleType int toggle) {
mHandler.obtainMessage(MSG_SET_FIREWALL_RULES, chain, toggle, uidRules).sendToTarget();
if (uidRules != null) {
setUidFirewallRulesUL(chain, uidRules);
}
if (toggle != CHAIN_TOGGLE_NONE) {
enableFirewallChainUL(chain, toggle == CHAIN_TOGGLE_ENABLE);
}
}
/**
@@ -4079,7 +4071,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
* here to netd. It will clean up dead rules and make sure the target chain only contains rules
* specified here.
*/
private void setUidFirewallRules(int chain, SparseIntArray uidRules) {
private void setUidFirewallRulesUL(int chain, SparseIntArray uidRules) {
try {
int size = uidRules.size();
int[] uids = new int[size];