diff --git a/src/com/android/settings/core/instrumentation/SharedPreferencesLogger.java b/src/com/android/settings/core/instrumentation/SharedPreferencesLogger.java index a5efcc1f95e..6c23b395b72 100644 --- a/src/com/android/settings/core/instrumentation/SharedPreferencesLogger.java +++ b/src/com/android/settings/core/instrumentation/SharedPreferencesLogger.java @@ -21,6 +21,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.AsyncTask; import android.text.TextUtils; +import android.util.Pair; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.overlay.FeatureFactory; @@ -111,13 +112,17 @@ public class SharedPreferencesLogger implements SharedPreferences { return; } // Pref key exists in set, log it's change in metrics. - mMetricsFeature.count(mContext, prefKey + "|" + value, 1); + mMetricsFeature.action(mContext, MetricsEvent.ACTION_SETTINGS_PREFERENCE_CHANGE, + Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_NAME, prefKey), + Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_VALUE, value)); } private void logPackageName(String key, String value) { - mMetricsFeature.count(mContext, mTag + "/" + key, 1); + final String prefKey = mTag + "/" + key; + mMetricsFeature.action(mContext, MetricsEvent.ACTION_SETTINGS_PREFERENCE_CHANGE, + Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_NAME, prefKey)); mMetricsFeature.action(mContext, MetricsEvent.ACTION_GENERIC_PACKAGE, - mTag + "/" + key + "|" + value); + prefKey + "|" + value); } private void safeLogValue(String key, String value) { diff --git a/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java b/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java index eeaa1751864..763d6e35120 100644 --- a/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java +++ b/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java @@ -17,6 +17,7 @@ package com.android.settings.core.instrumentation; import android.content.Context; import android.content.SharedPreferences; +import android.util.Pair; import com.android.settings.SettingsRobolectricTestRunner; import com.android.settings.TestConfig; @@ -32,7 +33,6 @@ import org.robolectric.annotation.Config; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -71,7 +71,8 @@ public class SharedPreferenceLoggerTest { editor.putInt(TEST_KEY, 2); editor.putInt(TEST_KEY, 2); - verify(mMetricsFeature, times(6)).count(any(Context.class), anyString(), anyInt()); + verify(mMetricsFeature, times(6)).action(any(Context.class), anyInt(), + any(Pair.class), any(Pair.class)); } @Test @@ -83,7 +84,8 @@ public class SharedPreferenceLoggerTest { editor.putBoolean(TEST_KEY, false); editor.putBoolean(TEST_KEY, false); - verify(mMetricsFeature, times(4)).count(any(Context.class), anyString(), anyInt()); + verify(mMetricsFeature, times(4)).action(any(Context.class), anyInt(), + any(Pair.class), any(Pair.class)); } @Test @@ -95,7 +97,8 @@ public class SharedPreferenceLoggerTest { editor.putLong(TEST_KEY, 1); editor.putLong(TEST_KEY, 2); - verify(mMetricsFeature, times(4)).count(any(Context.class), anyString(), anyInt()); + verify(mMetricsFeature, times(4)).action(any(Context.class), anyInt(), + any(Pair.class), any(Pair.class)); } @Test @@ -107,7 +110,8 @@ public class SharedPreferenceLoggerTest { editor.putFloat(TEST_KEY, 1); editor.putFloat(TEST_KEY, 2); - verify(mMetricsFeature, times(4)).count(any(Context.class), anyString(), anyInt()); + verify(mMetricsFeature, times(4)).action(any(Context.class), anyInt(), + any(Pair.class), any(Pair.class)); } }