Merge "Extract method to build preference count logging's name." into oc-dr1-dev
am: 5fb56c5b37
Change-Id: I7974307f83886ab9e075eee4ef347ef95562acef
This commit is contained in:
@@ -108,7 +108,7 @@ public class SharedPreferencesLogger implements SharedPreferences {
|
||||
}
|
||||
|
||||
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)) {
|
||||
// Pref key doesn't exist in set, this is initial display so we skip metrics but
|
||||
// keeps track of this key.
|
||||
@@ -116,7 +116,7 @@ public class SharedPreferencesLogger implements SharedPreferences {
|
||||
return;
|
||||
}
|
||||
// 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;
|
||||
if (value instanceof Long) {
|
||||
@@ -131,11 +131,10 @@ public class SharedPreferencesLogger implements SharedPreferences {
|
||||
} else if (value instanceof Float) {
|
||||
valueData = Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_FLOAT_VALUE,
|
||||
value);
|
||||
} else if (value instanceof String){
|
||||
valueData = Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_VALUE,
|
||||
value);
|
||||
} else if (value instanceof String) {
|
||||
valueData = Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_VALUE, value);
|
||||
} else {
|
||||
Log.w(LOG_TAG, "Tried to log unloggable object" + value);
|
||||
Log.w(LOG_TAG, "Tried to log unloggable object" + value);
|
||||
valueData = null;
|
||||
}
|
||||
if (valueData != null) {
|
||||
@@ -157,6 +156,14 @@ public class SharedPreferencesLogger implements SharedPreferences {
|
||||
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> {
|
||||
@Override
|
||||
protected Void doInBackground(String... params) {
|
||||
|
Reference in New Issue
Block a user