aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqingqi <qingqi@google.com>2023-11-30 22:33:27 +0000
committerQingqi Lei <qingqi@google.com>2023-12-06 20:40:38 +0000
commit7e913029e6393382bbf45cac744c70ebe7b5b845 (patch)
treed291a8ee8464917bac073be1ea81074cea94b98e
parentb0e5784d3807688a7ad37f7f955e9d3b4233131b (diff)
downloadtelephony-7e913029e6393382bbf45cac744c70ebe7b5b845.tar.gz
Shorten cooldown time service state metrics
Test: m, manually inspect metric log Bug: 310630240 Change-Id: I1c7e40d516b2647e5fc3b34301518b269cb38aff
-rw-r--r--src/java/com/android/internal/telephony/metrics/MetricsCollector.java36
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/metrics/MetricsCollectorTest.java6
2 files changed, 36 insertions, 6 deletions
diff --git a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
index 9866c741c0..e27d14b164 100644
--- a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
+++ b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
@@ -53,6 +53,7 @@ import static com.android.internal.telephony.TelephonyStatsLog.UCE_EVENT_STATS;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_RAT_USAGE;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__CALL_DURATION__CALL_DURATION_UNKNOWN;
+import static com.android.internal.telephony.util.TelephonyUtils.IS_DEBUGGABLE;
import android.app.StatsManager;
import android.content.Context;
@@ -136,16 +137,33 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
DBG ? 10L * MILLIS_PER_SECOND : 23L * MILLIS_PER_HOUR;
/**
+ * Sets atom pull cool down to 4 minutes for userdebug build.
+ *
+ * <p>Applies to certain atoms: CellularServiceState.
+ */
+ private static final long CELL_SERVICE_MIN_COOLDOWN_MILLIS =
+ DBG ? 10L * MILLIS_PER_SECOND :
+ IS_DEBUGGABLE ? 4L * MILLIS_PER_MINUTE : 23L * MILLIS_PER_HOUR;
+
+ /**
* Buckets with less than these many calls will be dropped.
*
* <p>Applies to metrics with duration fields. Currently used by voice call RAT usages.
*/
private static final long MIN_CALLS_PER_BUCKET = DBG ? 0L : 5L;
- /** Bucket size in milliseconds to round call durations into. */
+ /** Bucket size in milliseconds to round call durations info. */
private static final long DURATION_BUCKET_MILLIS =
DBG ? 2L * MILLIS_PER_SECOND : 5L * MILLIS_PER_MINUTE;
+ /**
+ * Sets smaller bucket size to round call durations for userdebug build.
+ *
+ * <p>Applies to certain atoms: CellularServiceState.
+ */
+ private static final long CELL_SERVICE_DURATION_BUCKET_MILLIS =
+ DBG || IS_DEBUGGABLE ? 2L * MILLIS_PER_SECOND : 5L * MILLIS_PER_MINUTE;
+
private final PersistAtomsStorage mStorage;
private final DeviceStateHelper mDeviceStateHelper;
private final StatsManager mStatsManager;
@@ -510,7 +528,7 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
// Include the latest durations
concludeServiceStateStats();
CellularServiceState[] persistAtoms =
- mStorage.getCellularServiceStates(MIN_COOLDOWN_MILLIS);
+ mStorage.getCellularServiceStates(CELL_SERVICE_MIN_COOLDOWN_MILLIS);
if (persistAtoms != null) {
// list is already shuffled when instances were inserted
Arrays.stream(persistAtoms)
@@ -930,7 +948,8 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
state.simSlotIndex,
state.isMultiSim,
state.carrierId,
- roundAndConvertMillisToSeconds(state.totalTimeMillis),
+ roundAndConvertMillisToSeconds(state.totalTimeMillis,
+ CELL_SERVICE_DURATION_BUCKET_MILLIS),
state.isEmergencyOnly,
state.isInternetPdnUp,
state.foldState,
@@ -1364,8 +1383,15 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback {
* Rounds the duration and converts it from milliseconds to seconds.
*/
private static int roundAndConvertMillisToSeconds(long valueMillis) {
- long roundedValueMillis = Math.round((double) valueMillis / DURATION_BUCKET_MILLIS)
- * DURATION_BUCKET_MILLIS;
+ return roundAndConvertMillisToSeconds(valueMillis, DURATION_BUCKET_MILLIS);
+ }
+
+ /**
+ * Rounds the duration and converts it from milliseconds to seconds.
+ */
+ private static int roundAndConvertMillisToSeconds(long valueMillis, long durationBucketSize) {
+ long roundedValueMillis = Math.round((double) valueMillis / durationBucketSize)
+ * durationBucketSize;
return (int) (roundedValueMillis / MILLIS_PER_SECOND);
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/metrics/MetricsCollectorTest.java b/tests/telephonytests/src/com/android/internal/telephony/metrics/MetricsCollectorTest.java
index 66bf48202e..b8ae8946f7 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/metrics/MetricsCollectorTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/metrics/MetricsCollectorTest.java
@@ -23,6 +23,7 @@ import static com.android.internal.telephony.TelephonyStatsLog.SIM_SLOT_STATE;
import static com.android.internal.telephony.TelephonyStatsLog.SUPPORTED_RADIO_ACCESS_FAMILY;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_RAT_USAGE;
import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION;
+import static com.android.internal.telephony.util.TelephonyUtils.IS_DEBUGGABLE;
import static com.google.common.truth.Truth.assertThat;
@@ -67,6 +68,8 @@ public class MetricsCollectorTest extends TelephonyTest {
.setCoolDownMillis(24L * 3600L * 1000L)
.build();
private static final long MIN_COOLDOWN_MILLIS = 23L * 3600L * 1000L;
+ private static final long CELL_SERVICE_MIN_COOLDOWN_MILLIS =
+ IS_DEBUGGABLE ? 4L * 60L * 1000L : MIN_COOLDOWN_MILLIS;
private static final long MIN_CALLS_PER_BUCKET = 5L;
// NOTE: these fields are currently 32-bit internally and padded to 64-bit by TelephonyManager
@@ -398,7 +401,8 @@ public class MetricsCollectorTest extends TelephonyTest {
assertThat(actualAtoms).hasSize(0);
assertThat(result).isEqualTo(StatsManager.PULL_SKIP);
- verify(mPersistAtomsStorage, times(1)).getCellularServiceStates(eq(MIN_COOLDOWN_MILLIS));
+ verify(mPersistAtomsStorage, times(1)).getCellularServiceStates(
+ eq(CELL_SERVICE_MIN_COOLDOWN_MILLIS));
verifyNoMoreInteractions(mPersistAtomsStorage);
}