Fixed elapsed_time_millis in SettingsUIChanged event

This change stores timestamp when received com.google.android.setupwizard.SETUP_WIZARD_FINISHED. This timestamp will be used to calculate elapsed_time_millis for SettingsUIChanged event after SUW complete. This enables to analyze how the user uses Settings in a specific time span after setup.

Bug: 344466251
Test: metrics related change only
Flag: EXEMPT metrics change only

Change-Id: I85b15f1eb5e5a4502a27d8588bb01e59b7ad83b5
This commit is contained in:
David Liu
2024-09-18 01:00:07 +00:00
parent ad856d326f
commit 2f39a808fc
4 changed files with 21 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import com.android.settings.core.instrumentation.ElapsedTimeUtils;
import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
@@ -96,4 +97,12 @@ public class SettingsInitializeTest {
assertThat(updatedShortcuts).hasSize(1);
assertThat(updatedShortcuts.get(0)).isSameInstanceAs(info);
}
@Test
public void onReceive_suwFinished_shouldHaveElapsedTime() {
mSettingsInitialize.onReceive(mContext, new Intent(SetupWizardUtils.ACTION_SETUP_WIZARD_FINISHED));
final long elapsedTime = ElapsedTimeUtils.getElapsedTime(System.currentTimeMillis());
assertThat(elapsedTime).isNotEqualTo(-1L);
}
}