Move config_apf* resources to NetworkStack

The resources are only read by NetworkStack through their respective
ApfCapabilities SystemApi methods.
As the resources are being migrated out of frameworks/base resources
anyway, move them directly to NetworkStack instead of moving them to
ServiceConnectivityResources.

Also test that the framework resources are not overlaid or modified.
This should avoid OEM integration errors where the overlays are kept as
in R, without overlaying the resource in the NetworkStack package.

Bug: 185850634
Test: atest CtsNetTestCases
BYPASS_INCLUSIVE_LANGUAGE_REASON=Need to mention legacy APIs

Change-Id: I7a15ddcad5af11fa307d9dbe3a77b31a1179e5b3
This commit is contained in:
Remi NGUYEN VAN
2021-04-23 15:39:02 +09:00
parent bf29bd3457
commit 0aa7a4747f
4 changed files with 37 additions and 44 deletions

View File

@@ -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.
*/
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 int id = systemRes.getIdentifier("config_apfDrop802_3Frames", "bool", "android");
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.
*/
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 int id = systemRes.getIdentifier("config_apfEthTypeBlackList", "array", "android");
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);
}
}