Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5fb56c5b authored by Fan Zhang's avatar Fan Zhang Committed by Android (Google) Code Review
Browse files

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

parents a7e10e03 ae70d2cd
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -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) {
@@ -132,8 +132,7 @@ public class SharedPreferencesLogger implements SharedPreferences {
            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);
            valueData = Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_VALUE, value);
        } else {
            Log.w(LOG_TAG, "Tried to log unloggable object" + value);
            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) {