Merge "Move config_apf* resources to NetworkStack" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1ac0e834c9
@@ -131,43 +131,21 @@ public final class ApfCapabilities implements Parcelable {
|
|||||||
* @return Whether the APF Filter in the device should filter out IEEE 802.3 Frames.
|
* @return Whether the APF Filter in the device should filter out IEEE 802.3 Frames.
|
||||||
*/
|
*/
|
||||||
public static boolean getApfDrop8023Frames() {
|
public static boolean getApfDrop8023Frames() {
|
||||||
// TODO(b/183076074): remove reading resources from system resources
|
// TODO: deprecate/remove this method (now unused in the platform), as the resource was
|
||||||
|
// moved to NetworkStack.
|
||||||
final Resources systemRes = Resources.getSystem();
|
final Resources systemRes = Resources.getSystem();
|
||||||
final int id = systemRes.getIdentifier("config_apfDrop802_3Frames", "bool", "android");
|
final int id = systemRes.getIdentifier("config_apfDrop802_3Frames", "bool", "android");
|
||||||
return systemRes.getBoolean(id);
|
return systemRes.getBoolean(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Whether the APF Filter in the device should filter out IEEE 802.3 Frames.
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static boolean getApfDrop8023Frames(@NonNull Context context) {
|
|
||||||
final ConnectivityResources res = getResources(context);
|
|
||||||
// TODO(b/183076074): use R.bool.config_apfDrop802_3Frames directly
|
|
||||||
final int id = res.get().getIdentifier("config_apfDrop802_3Frames", "bool",
|
|
||||||
res.getResourcesContext().getPackageName());
|
|
||||||
return res.get().getBoolean(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return An array of denylisted EtherType, packets with EtherTypes within it will be dropped.
|
* @return An array of denylisted EtherType, packets with EtherTypes within it will be dropped.
|
||||||
*/
|
*/
|
||||||
public static @NonNull int[] getApfEtherTypeBlackList() {
|
public static @NonNull int[] getApfEtherTypeBlackList() {
|
||||||
// TODO(b/183076074): remove reading resources from system resources
|
// TODO: deprecate/remove this method (now unused in the platform), as the resource was
|
||||||
|
// moved to NetworkStack.
|
||||||
final Resources systemRes = Resources.getSystem();
|
final Resources systemRes = Resources.getSystem();
|
||||||
final int id = systemRes.getIdentifier("config_apfEthTypeBlackList", "array", "android");
|
final int id = systemRes.getIdentifier("config_apfEthTypeBlackList", "array", "android");
|
||||||
return systemRes.getIntArray(id);
|
return systemRes.getIntArray(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return An array of denylisted EtherType, packets with EtherTypes within it will be dropped.
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static @NonNull int[] getApfEtherTypeDenyList(@NonNull Context context) {
|
|
||||||
final ConnectivityResources res = getResources(context);
|
|
||||||
// TODO(b/183076074): use R.array.config_apfEthTypeDenyList directly
|
|
||||||
final int id = res.get().getIdentifier("config_apfEthTypeDenyList", "array",
|
|
||||||
res.getResourcesContext().getPackageName());
|
|
||||||
return res.get().getIntArray(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,22 +52,6 @@
|
|||||||
<item>12,60000</item><!-- mobile_cbs -->
|
<item>12,60000</item><!-- mobile_cbs -->
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Whether the APF Filter in the device should filter out IEEE 802.3 Frames
|
|
||||||
Those frames are identified by the field Eth-type having values
|
|
||||||
less than 0x600 -->
|
|
||||||
<bool translatable="false" name="config_apfDrop802_3Frames">true</bool>
|
|
||||||
|
|
||||||
<!-- An array of Denylisted EtherType, packets with EtherTypes within this array
|
|
||||||
will be dropped
|
|
||||||
TODO: need to put proper values, these are for testing purposes only -->
|
|
||||||
<integer-array translatable="false" name="config_apfEthTypeDenyList">
|
|
||||||
<item>0x88A2</item>
|
|
||||||
<item>0x88A4</item>
|
|
||||||
<item>0x88B8</item>
|
|
||||||
<item>0x88CD</item>
|
|
||||||
<item>0x88E3</item>
|
|
||||||
</integer-array>
|
|
||||||
|
|
||||||
<!-- Default supported concurrent socket keepalive slots per transport type, used by
|
<!-- Default supported concurrent socket keepalive slots per transport type, used by
|
||||||
ConnectivityManager.createSocketKeepalive() for calculating the number of keepalive
|
ConnectivityManager.createSocketKeepalive() for calculating the number of keepalive
|
||||||
offload slots that should be reserved for privileged access. This string array should be
|
offload slots that should be reserved for privileged access. This string array should be
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
<item type="string" name="config_networkCaptivePortalServerUrl"/>
|
<item type="string" name="config_networkCaptivePortalServerUrl"/>
|
||||||
<item type="integer" name="config_networkTransitionTimeout"/>
|
<item type="integer" name="config_networkTransitionTimeout"/>
|
||||||
<item type="array" name="config_wakeonlan_supported_interfaces"/>
|
<item type="array" name="config_wakeonlan_supported_interfaces"/>
|
||||||
<item type="bool" name="config_apfDrop802_3Frames"/>
|
|
||||||
<item type="array" name="config_apfEthTypeDenyList"/>
|
|
||||||
<item type="integer" name="config_networkMeteredMultipathPreference"/>
|
<item type="integer" name="config_networkMeteredMultipathPreference"/>
|
||||||
<item type="array" name="config_networkSupportedKeepaliveCount"/>
|
<item type="array" name="config_networkSupportedKeepaliveCount"/>
|
||||||
<item type="integer" name="config_networkAvoidBadWifi"/>
|
<item type="integer" name="config_networkAvoidBadWifi"/>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.net.apf;
|
|||||||
|
|
||||||
import static com.android.testutils.ParcelUtils.assertParcelSane;
|
import static com.android.testutils.ParcelUtils.assertParcelSane;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
@@ -25,12 +26,17 @@ import static org.junit.Assert.assertNotNull;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.test.InstrumentationRegistry;
|
import androidx.test.InstrumentationRegistry;
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule;
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@@ -39,6 +45,9 @@ import java.util.Arrays;
|
|||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class ApfCapabilitiesTest {
|
public class ApfCapabilitiesTest {
|
||||||
|
@Rule
|
||||||
|
public final DevSdkIgnoreRule mIgnoreRule = new DevSdkIgnoreRule();
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -85,6 +94,17 @@ public class ApfCapabilitiesTest {
|
|||||||
assertEquals(shouldDrop8023Frames, actual);
|
assertEquals(shouldDrop8023Frames, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||||
|
public void testGetApfDrop8023Frames_S() {
|
||||||
|
// IpClient does not call getApfDrop8023Frames() since S, so any customization of the return
|
||||||
|
// value on S+ is a configuration error as it will not be used by IpClient.
|
||||||
|
assertTrue("android.R.bool.config_apfDrop802_3Frames has been modified to false, but "
|
||||||
|
+ "starting from S its value is not used by IpClient. If the modification is "
|
||||||
|
+ "intentional, use a runtime resource overlay for the NetworkStack package to "
|
||||||
|
+ "overlay com.android.networkstack.R.bool.config_apfDrop802_3Frames instead.",
|
||||||
|
ApfCapabilities.getApfDrop8023Frames());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetApfEtherTypeBlackList() {
|
public void testGetApfEtherTypeBlackList() {
|
||||||
// Get com.android.internal.R.array.config_apfEthTypeBlackList. The test cannot directly
|
// Get com.android.internal.R.array.config_apfEthTypeBlackList. The test cannot directly
|
||||||
@@ -96,4 +116,17 @@ public class ApfCapabilitiesTest {
|
|||||||
assertNotNull(actual);
|
assertNotNull(actual);
|
||||||
assertTrue(Arrays.equals(blacklistedEtherTypeArray, actual));
|
assertTrue(Arrays.equals(blacklistedEtherTypeArray, actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||||
|
public void testGetApfEtherTypeBlackList_S() {
|
||||||
|
// IpClient does not call getApfEtherTypeBlackList() since S, so any customization of the
|
||||||
|
// return value on S+ is a configuration error as it will not be used by IpClient.
|
||||||
|
assertArrayEquals("android.R.array.config_apfEthTypeBlackList has been modified, but "
|
||||||
|
+ "starting from S its value is not used by IpClient. If the modification "
|
||||||
|
+ "is intentional, use a runtime resource overlay for the NetworkStack "
|
||||||
|
+ "package to overlay "
|
||||||
|
+ "com.android.networkstack.R.array.config_apfEthTypeDenyList instead.",
|
||||||
|
new int[] { 0x88a2, 0x88a4, 0x88b8, 0x88cd, 0x88e3 },
|
||||||
|
ApfCapabilities.getApfEtherTypeBlackList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user