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;
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) {
import android.content.Context;
import android.content.SharedPreferences;
+import android.util.Pair;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
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;
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
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
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
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));
}
}