blob: e1a390947904df1d0985f19b51cdbd2d40a53c61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package com.google.android.setupcompat.logging.internal;
import android.os.Bundle;
import com.google.android.setupcompat.logging.CustomEvent;
import com.google.android.setupcompat.logging.MetricKey;
import com.google.android.setupcompat.logging.internal.SetupMetricsLoggingConstants.MetricBundleKeys;
/** Collection of helper methods for reading and writing {@link CustomEvent}, {@link MetricKey}. */
public final class MetricBundleConverter {
public static Bundle createBundleForLogging(CustomEvent customEvent) {
Bundle bundle = new Bundle();
bundle.putParcelable(MetricBundleKeys.CUSTOM_EVENT_BUNDLE, CustomEvent.toBundle(customEvent));
return bundle;
}
public static Bundle createBundleForLoggingCounter(MetricKey counterName, int times) {
Bundle bundle = new Bundle();
bundle.putParcelable(MetricBundleKeys.METRIC_KEY_BUNDLE, MetricKey.fromMetricKey(counterName));
bundle.putInt(MetricBundleKeys.COUNTER_INT, times);
return bundle;
}
public static Bundle createBundleForLoggingTimer(MetricKey timerName, long timeInMillis) {
Bundle bundle = new Bundle();
bundle.putParcelable(MetricBundleKeys.METRIC_KEY_BUNDLE, MetricKey.fromMetricKey(timerName));
bundle.putLong(MetricBundleKeys.TIME_MILLIS_LONG, timeInMillis);
return bundle;
}
private MetricBundleConverter() {
throw new AssertionError("Cannot instantiate MetricBundleConverter");
}
}
|