Merge "Extract method to build preference count logging's name." into oc-dr1-dev
This commit is contained in:
@@ -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) {
|
||||||
@@ -131,11 +131,10 @@ public class SharedPreferencesLogger implements SharedPreferences {
|
|||||||
} else if (value instanceof Float) {
|
} else if (value instanceof Float) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
if (valueData != null) {
|
if (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) {
|
||||||
|
Reference in New Issue
Block a user