Merge "Remove unnecessary null check"
This commit is contained in:
@@ -25,7 +25,6 @@ import static android.net.ConnectivityManager.FIREWALL_CHAIN_POWERSAVE;
|
|||||||
import static android.net.ConnectivityManager.FIREWALL_CHAIN_RESTRICTED;
|
import static android.net.ConnectivityManager.FIREWALL_CHAIN_RESTRICTED;
|
||||||
import static android.net.ConnectivityManager.FIREWALL_CHAIN_STANDBY;
|
import static android.net.ConnectivityManager.FIREWALL_CHAIN_STANDBY;
|
||||||
import static android.system.OsConstants.EINVAL;
|
import static android.system.OsConstants.EINVAL;
|
||||||
import static android.system.OsConstants.ENOENT;
|
|
||||||
import static android.system.OsConstants.EOPNOTSUPP;
|
import static android.system.OsConstants.EOPNOTSUPP;
|
||||||
|
|
||||||
import android.net.INetd;
|
import android.net.INetd;
|
||||||
@@ -239,11 +238,6 @@ public class BpfNetMaps {
|
|||||||
try {
|
try {
|
||||||
synchronized (sUidRulesConfigBpfMapLock) {
|
synchronized (sUidRulesConfigBpfMapLock) {
|
||||||
final U32 config = sConfigurationMap.getValue(UID_RULES_CONFIGURATION_KEY);
|
final U32 config = sConfigurationMap.getValue(UID_RULES_CONFIGURATION_KEY);
|
||||||
if (config == null) {
|
|
||||||
throw new ServiceSpecificException(ENOENT,
|
|
||||||
"Unable to get firewall chain status: sConfigurationMap does not have"
|
|
||||||
+ " entry for UID_RULES_CONFIGURATION_KEY");
|
|
||||||
}
|
|
||||||
final long newConfig = enable ? (config.val | match) : (config.val & ~match);
|
final long newConfig = enable ? (config.val | match) : (config.val & ~match);
|
||||||
sConfigurationMap.updateEntry(UID_RULES_CONFIGURATION_KEY, new U32(newConfig));
|
sConfigurationMap.updateEntry(UID_RULES_CONFIGURATION_KEY, new U32(newConfig));
|
||||||
}
|
}
|
||||||
@@ -268,11 +262,6 @@ public class BpfNetMaps {
|
|||||||
final long match = getMatchByFirewallChain(childChain);
|
final long match = getMatchByFirewallChain(childChain);
|
||||||
try {
|
try {
|
||||||
final U32 config = sConfigurationMap.getValue(UID_RULES_CONFIGURATION_KEY);
|
final U32 config = sConfigurationMap.getValue(UID_RULES_CONFIGURATION_KEY);
|
||||||
if (config == null) {
|
|
||||||
throw new ServiceSpecificException(ENOENT,
|
|
||||||
"Unable to get firewall chain status: sConfigurationMap does not have"
|
|
||||||
+ " entry for UID_RULES_CONFIGURATION_KEY");
|
|
||||||
}
|
|
||||||
return (config.val & match) != 0;
|
return (config.val & match) != 0;
|
||||||
} catch (ErrnoException e) {
|
} catch (ErrnoException e) {
|
||||||
throw new ServiceSpecificException(e.errno,
|
throw new ServiceSpecificException(e.errno,
|
||||||
|
|||||||
@@ -174,14 +174,6 @@ public final class BpfNetMapsTest {
|
|||||||
assertThrows(expected, () -> mBpfNetMaps.isChainEnabled(1000 /* childChain */));
|
assertThrows(expected, () -> mBpfNetMaps.isChainEnabled(1000 /* childChain */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
|
||||||
public void testIsChainEnabledMissingConfiguration() {
|
|
||||||
// sConfigurationMap does not have entry for UID_RULES_CONFIGURATION_KEY
|
|
||||||
assertThrows(ServiceSpecificException.class,
|
|
||||||
() -> mBpfNetMaps.isChainEnabled(FIREWALL_CHAIN_DOZABLE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@IgnoreAfter(Build.VERSION_CODES.S_V2)
|
@IgnoreAfter(Build.VERSION_CODES.S_V2)
|
||||||
public void testIsChainEnabledBeforeT() {
|
public void testIsChainEnabledBeforeT() {
|
||||||
@@ -251,14 +243,6 @@ public final class BpfNetMapsTest {
|
|||||||
() -> mBpfNetMaps.setChildChain(1000 /* childChain */, true /* enable */));
|
() -> mBpfNetMaps.setChildChain(1000 /* childChain */, true /* enable */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
|
||||||
public void testSetChildChainMissingConfiguration() {
|
|
||||||
// sConfigurationMap does not have entry for UID_RULES_CONFIGURATION_KEY
|
|
||||||
assertThrows(ServiceSpecificException.class,
|
|
||||||
() -> mBpfNetMaps.setChildChain(FIREWALL_CHAIN_DOZABLE, true /* enable */));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@IgnoreAfter(Build.VERSION_CODES.S_V2)
|
@IgnoreAfter(Build.VERSION_CODES.S_V2)
|
||||||
public void testSetChildChainBeforeT() {
|
public void testSetChildChainBeforeT() {
|
||||||
|
|||||||
Reference in New Issue
Block a user