Loading packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java +16 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,22 @@ public class MetricsFeatureProvider { sourceMetricsCategory); } /** * Logs an event when the intent is started by Profile select dialog. * * @return true if the intent is loggable, otherwise false */ public boolean logStartedIntentWithProfile(Intent intent, int sourceMetricsCategory, boolean isWorkProfile) { if (intent == null) { return false; } final ComponentName cn = intent.getComponent(); final String key = cn != null ? cn.flattenToString() : intent.getAction(); return logSettingsTileClick(key + (isWorkProfile ? "/work" : "/personal"), sourceMetricsCategory); } private boolean logSettingsTileClick(String logKey, int sourceMetricsCategory) { if (TextUtils.isEmpty(logKey)) { // Not loggable Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,38 @@ public class MetricsFeatureProviderTest { 0); } @Test public void logStartedIntentWithProfile_isPersonalProfile_shouldTagPersonal() { final Intent intent = new Intent().setComponent(new ComponentName("pkg", "cls")); final boolean loggable = mProvider.logStartedIntentWithProfile(intent, MetricsEvent.SETTINGS_GESTURES, false); assertThat(loggable).isTrue(); verify(mLogWriter).action( MetricsEvent.SETTINGS_GESTURES, MetricsEvent.ACTION_SETTINGS_TILE_CLICK, SettingsEnums.PAGE_UNKNOWN, "pkg/cls/personal", 0); } @Test public void logStartedIntentWithProfile_isWorkProfile_shouldTagWork() { final Intent intent = new Intent().setComponent(new ComponentName("pkg", "cls")); final boolean loggable = mProvider.logStartedIntentWithProfile(intent, MetricsEvent.SETTINGS_GESTURES, true); assertThat(loggable).isTrue(); verify(mLogWriter).action( MetricsEvent.SETTINGS_GESTURES, MetricsEvent.ACTION_SETTINGS_TILE_CLICK, SettingsEnums.PAGE_UNKNOWN, "pkg/cls/work", 0); } @Test public void getAttribution_noActivity_shouldReturnUnknown() { assertThat(mProvider.getAttribution(null /* activity */)) Loading Loading
packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java +16 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,22 @@ public class MetricsFeatureProvider { sourceMetricsCategory); } /** * Logs an event when the intent is started by Profile select dialog. * * @return true if the intent is loggable, otherwise false */ public boolean logStartedIntentWithProfile(Intent intent, int sourceMetricsCategory, boolean isWorkProfile) { if (intent == null) { return false; } final ComponentName cn = intent.getComponent(); final String key = cn != null ? cn.flattenToString() : intent.getAction(); return logSettingsTileClick(key + (isWorkProfile ? "/work" : "/personal"), sourceMetricsCategory); } private boolean logSettingsTileClick(String logKey, int sourceMetricsCategory) { if (TextUtils.isEmpty(logKey)) { // Not loggable Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,38 @@ public class MetricsFeatureProviderTest { 0); } @Test public void logStartedIntentWithProfile_isPersonalProfile_shouldTagPersonal() { final Intent intent = new Intent().setComponent(new ComponentName("pkg", "cls")); final boolean loggable = mProvider.logStartedIntentWithProfile(intent, MetricsEvent.SETTINGS_GESTURES, false); assertThat(loggable).isTrue(); verify(mLogWriter).action( MetricsEvent.SETTINGS_GESTURES, MetricsEvent.ACTION_SETTINGS_TILE_CLICK, SettingsEnums.PAGE_UNKNOWN, "pkg/cls/personal", 0); } @Test public void logStartedIntentWithProfile_isWorkProfile_shouldTagWork() { final Intent intent = new Intent().setComponent(new ComponentName("pkg", "cls")); final boolean loggable = mProvider.logStartedIntentWithProfile(intent, MetricsEvent.SETTINGS_GESTURES, true); assertThat(loggable).isTrue(); verify(mLogWriter).action( MetricsEvent.SETTINGS_GESTURES, MetricsEvent.ACTION_SETTINGS_TILE_CLICK, SettingsEnums.PAGE_UNKNOWN, "pkg/cls/work", 0); } @Test public void getAttribution_noActivity_shouldReturnUnknown() { assertThat(mProvider.getAttribution(null /* activity */)) Loading