Enable APF counter metrics on V+ devices with APFv4+
This commit enables the collection of APF counter metrics for all V and
later devices that support APFv4 and above. The introduction of
ApfIntegrationTest in Android V provides some assurance that the APF
counter region can be collected correctly. With the significant number
of APFv6 features introduced in Android B, collecting counter metrics
from non-Pixel devices will be valuable. The polling interval is set to
30 minutes to minimize potential battery impact. A follow-up CL will
improve polling accuracy and reduce bias by transitioning from a
TimerFD-based solution.
Test: TH
Flag: EXEMPT mainline
Change-Id: I82a17a036ae31af81f30314041f7fa3f7c967ffa
diff --git a/src/android/net/apf/ApfFilter.java b/src/android/net/apf/ApfFilter.java
index 97821a3..6fb8ad8 100644
--- a/src/android/net/apf/ApfFilter.java
+++ b/src/android/net/apf/ApfFilter.java
@@ -380,7 +380,6 @@
private final InterfaceParams mInterfaceParams;
private final TokenBucket mTokenBucket;
- @VisibleForTesting
public final int mApfVersionSupported;
@VisibleForTesting
@NonNull
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java
index c89c2ea..cfb9137 100644
--- a/src/android/net/ip/IpClient.java
+++ b/src/android/net/ip/IpClient.java
@@ -658,7 +658,7 @@
static final String CONFIG_APF_COUNTER_POLLING_INTERVAL_SECS =
"ipclient_apf_counter_polling_interval_secs";
@VisibleForTesting
- static final int DEFAULT_APF_COUNTER_POLLING_INTERVAL_SECS = 300;
+ static final int DEFAULT_APF_COUNTER_POLLING_INTERVAL_SECS = 1800;
// Used to wait for the provisioning to complete eventually and then decide the target
// network type, which gives the accurate hint to set DTIM multiplier. Per current IPv6
@@ -1094,8 +1094,8 @@
mApfCounterPollingIntervalMs = mDependencies.getDeviceConfigPropertyInt(
CONFIG_APF_COUNTER_POLLING_INTERVAL_SECS,
DEFAULT_APF_COUNTER_POLLING_INTERVAL_SECS) * DateUtils.SECOND_IN_MILLIS;
- mEnableApfPollingCounters = mDependencies.isFeatureEnabled(context,
- APF_POLLING_COUNTERS_VERSION);
+ mEnableApfPollingCounters = mDependencies.isFeatureNotChickenedOut(context,
+ APF_POLLING_COUNTERS_VERSION) && SdkLevel.isAtLeastV();
mIsAcceptRaMinLftEnabled =
SdkLevel.isAtLeastV() || mDependencies.isFeatureEnabled(context,
IPCLIENT_IGNORE_LOW_RA_LIFETIME_VERSION);
@@ -3884,7 +3884,7 @@
break;
case CMD_UPDATE_APF_DATA_SNAPSHOT:
- if (mApfFilter != null) {
+ if (mApfFilter != null && mApfFilter.mApfVersionSupported >= 4) {
// We prevents calls to readPacketFilterRam() when mApfFilter is null.
// This is correct because any data read would be discarded when
// processing the EVENT_READ_PACKET_FILTER_COMPLETE event if no