- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
package com.google.firebase.installations;
|
|
|
|
import android.text.TextUtils;
|
|
import com.facebook.internal.security.CertificateUtil;
|
|
import com.google.firebase.installations.local.PersistedInstallationEntry;
|
|
import com.google.firebase.installations.time.Clock;
|
|
import com.google.firebase.installations.time.SystemClock;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.regex.Pattern;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public final class Utils {
|
|
public static Utils singleton;
|
|
public final Clock clock;
|
|
public static final long AUTH_TOKEN_EXPIRATION_BUFFER_IN_SECS = TimeUnit.HOURS.toSeconds(1);
|
|
public static final Pattern API_KEY_FORMAT = Pattern.compile("\\AA[\\w-]{38}\\z");
|
|
|
|
public Utils(Clock clock) {
|
|
this.clock = clock;
|
|
}
|
|
|
|
public static Utils getInstance() {
|
|
return getInstance(SystemClock.getInstance());
|
|
}
|
|
|
|
public static Utils getInstance(Clock clock) {
|
|
if (singleton == null) {
|
|
singleton = new Utils(clock);
|
|
}
|
|
return singleton;
|
|
}
|
|
|
|
public boolean isAuthTokenExpired(PersistedInstallationEntry persistedInstallationEntry) {
|
|
return TextUtils.isEmpty(persistedInstallationEntry.getAuthToken()) || persistedInstallationEntry.getTokenCreationEpochInSecs() + persistedInstallationEntry.getExpiresInSecs() < currentTimeInSecs() + AUTH_TOKEN_EXPIRATION_BUFFER_IN_SECS;
|
|
}
|
|
|
|
public long currentTimeInSecs() {
|
|
return TimeUnit.MILLISECONDS.toSeconds(currentTimeInMillis());
|
|
}
|
|
|
|
public long currentTimeInMillis() {
|
|
return this.clock.currentTimeMillis();
|
|
}
|
|
|
|
public static boolean isValidAppIdFormat(String str) {
|
|
return str.contains(CertificateUtil.DELIMITER);
|
|
}
|
|
|
|
public static boolean isValidApiKeyFormat(String str) {
|
|
return API_KEY_FORMAT.matcher(str).matches();
|
|
}
|
|
|
|
public long getRandomDelayForSyncPrevention() {
|
|
return (long) (Math.random() * 1000.0d);
|
|
}
|
|
}
|