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) {
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) {