Loading services/java/com/android/server/net/NetworkPolicyManagerService.java +27 −0 Original line number Diff line number Diff line Loading @@ -1434,6 +1434,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { public void setNetworkPolicies(NetworkPolicy[] policies) { mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG); // Before clear and refresh mNetworkPolicy, we need to ensure all the // policies to be added are validated, otherwise this service will throw // IllegalArgumentException and cause system crash when updating network // template after receiving ACTION_NETWORK_STATS_UPDATED. validatePoliciesToSet(policies); maybeRefreshTrustedTime(); synchronized (mRulesLock) { mNetworkPolicy.clear(); Loading @@ -1448,6 +1454,27 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } /** * ensure the policies have valid template * * @param policies */ private void validatePoliciesToSet(NetworkPolicy[] policies) { for (NetworkPolicy policy : policies) { switch (policy.template.getMatchRule()) { case MATCH_MOBILE_3G_LOWER: case MATCH_MOBILE_4G: case MATCH_MOBILE_ALL: case MATCH_WIFI: case MATCH_ETHERNET: break; default: throw new IllegalArgumentException("unexpected template " + policy.template.getMatchRule()); } } } private void addNetworkPolicyLocked(NetworkPolicy policy) { mNetworkPolicy.put(policy.template, policy); Loading Loading
services/java/com/android/server/net/NetworkPolicyManagerService.java +27 −0 Original line number Diff line number Diff line Loading @@ -1434,6 +1434,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { public void setNetworkPolicies(NetworkPolicy[] policies) { mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG); // Before clear and refresh mNetworkPolicy, we need to ensure all the // policies to be added are validated, otherwise this service will throw // IllegalArgumentException and cause system crash when updating network // template after receiving ACTION_NETWORK_STATS_UPDATED. validatePoliciesToSet(policies); maybeRefreshTrustedTime(); synchronized (mRulesLock) { mNetworkPolicy.clear(); Loading @@ -1448,6 +1454,27 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } /** * ensure the policies have valid template * * @param policies */ private void validatePoliciesToSet(NetworkPolicy[] policies) { for (NetworkPolicy policy : policies) { switch (policy.template.getMatchRule()) { case MATCH_MOBILE_3G_LOWER: case MATCH_MOBILE_4G: case MATCH_MOBILE_ALL: case MATCH_WIFI: case MATCH_ETHERNET: break; default: throw new IllegalArgumentException("unexpected template " + policy.template.getMatchRule()); } } } private void addNetworkPolicyLocked(NetworkPolicy policy) { mNetworkPolicy.put(policy.template, policy); Loading