Merge "Extract method to build preference count logging's name." into oc-dr1-dev

am: 5fb56c5b37

Change-Id: Id4ae064a804b649b431913f02bde26013c1c87c2
This commit is contained in:
Fan Zhang
2017-07-26 06:07:30 +00:00
committed by android-build-merger

View File

@@ -108,7 +108,7 @@ public class SharedPreferencesLogger implements SharedPreferences {
} }
private void logValue(String key, Object value, boolean forceLog) { private void logValue(String key, Object value, boolean forceLog) {
final String prefKey = mTag + "/" + key; final String prefKey = buildPrefKey(mTag, key);
if (!forceLog && !mPreferenceKeySet.contains(prefKey)) { if (!forceLog && !mPreferenceKeySet.contains(prefKey)) {
// Pref key doesn't exist in set, this is initial display so we skip metrics but // Pref key doesn't exist in set, this is initial display so we skip metrics but
// keeps track of this key. // keeps track of this key.
@@ -116,7 +116,7 @@ public class SharedPreferencesLogger implements SharedPreferences {
return; return;
} }
// TODO: Remove count logging to save some resource. // TODO: Remove count logging to save some resource.
mMetricsFeature.count(mContext, prefKey + "|" + value, 1); mMetricsFeature.count(mContext, buildCountName(prefKey, value), 1);
final Pair<Integer, Object> valueData; final Pair<Integer, Object> valueData;
if (value instanceof Long) { if (value instanceof Long) {
@@ -132,8 +132,7 @@ public class SharedPreferencesLogger implements SharedPreferences {
valueData = Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_FLOAT_VALUE, valueData = Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_FLOAT_VALUE,
value); value);
} else if (value instanceof String) { } else if (value instanceof String) {
valueData = Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_VALUE, valueData = Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_VALUE, value);
value);
} else { } else {
Log.w(LOG_TAG, "Tried to log unloggable object" + value); Log.w(LOG_TAG, "Tried to log unloggable object" + value);
valueData = null; valueData = null;
@@ -157,6 +156,14 @@ public class SharedPreferencesLogger implements SharedPreferences {
new AsyncPackageCheck().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, key, value); new AsyncPackageCheck().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, key, value);
} }
public static String buildCountName(String prefKey, Object value) {
return prefKey + "|" + value;
}
public static String buildPrefKey(String tag, String key) {
return tag + "/" + key;
}
private class AsyncPackageCheck extends AsyncTask<String, Void, Void> { private class AsyncPackageCheck extends AsyncTask<String, Void, Void> {
@Override @Override
protected Void doInBackground(String... params) { protected Void doInBackground(String... params) {