what-the-bank/sources/com/google/firebase/abt/AbtExperimentInfo.java

79 lines
3.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.abt;
import android.text.TextUtils;
import com.google.firebase.analytics.connector.AnalyticsConnector;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
/* loaded from: classes2.dex */
public class AbtExperimentInfo {
private static final String[] ALL_REQUIRED_KEYS = {"experimentId", "experimentStartTime", "timeToLiveMillis", "triggerTimeoutMillis", "variantId"};
static final DateFormat protoTimestampStringParser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US);
private final String experimentId;
private final Date experimentStartTime;
private final long timeToLiveInMillis;
private final String triggerEventName;
private final long triggerTimeoutInMillis;
private final String variantId;
public AbtExperimentInfo(String str, String str2, String str3, Date date, long j, long j2) {
this.experimentId = str;
this.variantId = str2;
this.triggerEventName = str3;
this.experimentStartTime = date;
this.triggerTimeoutInMillis = j;
this.timeToLiveInMillis = j2;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static AbtExperimentInfo fromMap(Map<String, String> map) throws AbtException {
validateExperimentInfoMap(map);
try {
return new AbtExperimentInfo(map.get("experimentId"), map.get("variantId"), map.containsKey("triggerEvent") ? map.get("triggerEvent") : "", protoTimestampStringParser.parse(map.get("experimentStartTime")), Long.parseLong(map.get("triggerTimeoutMillis")), Long.parseLong(map.get("timeToLiveMillis")));
} catch (NumberFormatException e) {
throw new AbtException("Could not process experiment: one of the durations could not be converted into a long.", e);
} catch (ParseException e2) {
throw new AbtException("Could not process experiment: parsing experiment start time failed.", e2);
}
}
long getStartTimeInMillisSinceEpoch() {
return this.experimentStartTime.getTime();
}
private static void validateExperimentInfoMap(Map<String, String> map) throws AbtException {
ArrayList arrayList = new ArrayList();
for (String str : ALL_REQUIRED_KEYS) {
if (!map.containsKey(str)) {
arrayList.add(str);
}
}
if (!arrayList.isEmpty()) {
throw new AbtException(String.format("The following keys are missing from the experiment info map: %s", arrayList));
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public AnalyticsConnector.ConditionalUserProperty toConditionalUserProperty(String str) {
AnalyticsConnector.ConditionalUserProperty conditionalUserProperty = new AnalyticsConnector.ConditionalUserProperty();
conditionalUserProperty.origin = str;
conditionalUserProperty.creationTimestamp = getStartTimeInMillisSinceEpoch();
conditionalUserProperty.name = this.experimentId;
conditionalUserProperty.value = this.variantId;
conditionalUserProperty.triggerEventName = TextUtils.isEmpty(this.triggerEventName) ? null : this.triggerEventName;
conditionalUserProperty.triggerTimeout = this.triggerTimeoutInMillis;
conditionalUserProperty.timeToLive = this.timeToLiveInMillis;
return conditionalUserProperty;
}
/* JADX INFO: Access modifiers changed from: package-private */
public String getExperimentId() {
return this.experimentId;
}
}