package com.facebook.appevents.internal; import android.content.SharedPreferences; import android.preference.PreferenceManager; import com.facebook.FacebookSdk; import java.util.UUID; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes2.dex */ public final class SessionInfo { public static final Companion Companion = new Companion(null); private static final String INTERRUPTION_COUNT_KEY = "com.facebook.appevents.SessionInfo.interruptionCount"; private static final String LAST_SESSION_INFO_END_KEY = "com.facebook.appevents.SessionInfo.sessionEndTime"; private static final String LAST_SESSION_INFO_START_KEY = "com.facebook.appevents.SessionInfo.sessionStartTime"; private static final String SESSION_ID_KEY = "com.facebook.appevents.SessionInfo.sessionId"; private Long diskRestoreTime; private int interruptionCount; private UUID sessionId; private Long sessionLastEventTime; private final Long sessionStartTime; private SourceApplicationInfo sourceApplicationInfo; public SessionInfo(Long l, Long l2) { this(l, l2, null, 4, null); } public static final void clearSavedSessionFromDisk() { Companion.clearSavedSessionFromDisk(); } public static final SessionInfo getStoredSessionInfo() { return Companion.getStoredSessionInfo(); } public final int getInterruptionCount() { return this.interruptionCount; } public final UUID getSessionId() { return this.sessionId; } public final Long getSessionLastEventTime() { return this.sessionLastEventTime; } public final Long getSessionStartTime() { return this.sessionStartTime; } public final SourceApplicationInfo getSourceApplicationInfo() { return this.sourceApplicationInfo; } public final void incrementInterruptionCount() { this.interruptionCount++; } public final void setDiskRestoreTime(Long l) { this.diskRestoreTime = l; } public final void setSessionId(UUID uuid) { Intrinsics.checkNotNullParameter(uuid, ""); this.sessionId = uuid; } public final void setSessionLastEventTime(Long l) { this.sessionLastEventTime = l; } public final void setSourceApplicationInfo(SourceApplicationInfo sourceApplicationInfo) { this.sourceApplicationInfo = sourceApplicationInfo; } public SessionInfo(Long l, Long l2, UUID sessionId) { Intrinsics.checkNotNullParameter(sessionId, "sessionId"); this.sessionStartTime = l; this.sessionLastEventTime = l2; this.sessionId = sessionId; } /* JADX WARN: Illegal instructions before constructor call */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public /* synthetic */ SessionInfo(java.lang.Long r1, java.lang.Long r2, java.util.UUID r3, int r4, kotlin.jvm.internal.DefaultConstructorMarker r5) { /* r0 = this; r4 = r4 & 4 if (r4 == 0) goto Ld java.util.UUID r3 = java.util.UUID.randomUUID() java.lang.String r4 = "randomUUID()" kotlin.jvm.internal.Intrinsics.checkNotNullExpressionValue(r3, r4) Ld: r0.(r1, r2, r3) return */ throw new UnsupportedOperationException("Method not decompiled: com.facebook.appevents.internal.SessionInfo.(java.lang.Long, java.lang.Long, java.util.UUID, int, kotlin.jvm.internal.DefaultConstructorMarker):void"); } public final Long getDiskRestoreTime() { Long l = this.diskRestoreTime; if (l == null) { return 0L; } return l; } public final long getSessionLength() { Long l; if (this.sessionStartTime == null || (l = this.sessionLastEventTime) == null) { return 0L; } if (l != null) { return l.longValue() - this.sessionStartTime.longValue(); } throw new IllegalStateException("Required value was null.".toString()); } public final void writeSessionToDisk() { SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.getApplicationContext()).edit(); Long l = this.sessionStartTime; edit.putLong(LAST_SESSION_INFO_START_KEY, l == null ? 0L : l.longValue()); Long l2 = this.sessionLastEventTime; edit.putLong(LAST_SESSION_INFO_END_KEY, l2 != null ? l2.longValue() : 0L); edit.putInt(INTERRUPTION_COUNT_KEY, this.interruptionCount); edit.putString(SESSION_ID_KEY, this.sessionId.toString()); edit.apply(); SourceApplicationInfo sourceApplicationInfo = this.sourceApplicationInfo; if (sourceApplicationInfo == null || sourceApplicationInfo == null) { return; } sourceApplicationInfo.writeSourceApplicationInfoToDisk(); } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public final SessionInfo getStoredSessionInfo() { SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.getApplicationContext()); long j = defaultSharedPreferences.getLong(SessionInfo.LAST_SESSION_INFO_START_KEY, 0L); long j2 = defaultSharedPreferences.getLong(SessionInfo.LAST_SESSION_INFO_END_KEY, 0L); String string = defaultSharedPreferences.getString(SessionInfo.SESSION_ID_KEY, null); if (j == 0 || j2 == 0 || string == null) { return null; } SessionInfo sessionInfo = new SessionInfo(Long.valueOf(j), Long.valueOf(j2), null, 4, null); sessionInfo.interruptionCount = defaultSharedPreferences.getInt(SessionInfo.INTERRUPTION_COUNT_KEY, 0); sessionInfo.setSourceApplicationInfo(SourceApplicationInfo.Companion.getStoredSourceApplicatioInfo()); sessionInfo.setDiskRestoreTime(Long.valueOf(System.currentTimeMillis())); UUID fromString = UUID.fromString(string); Intrinsics.checkNotNullExpressionValue(fromString, "fromString(sessionIDStr)"); sessionInfo.setSessionId(fromString); return sessionInfo; } public final void clearSavedSessionFromDisk() { SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.getApplicationContext()).edit(); edit.remove(SessionInfo.LAST_SESSION_INFO_START_KEY); edit.remove(SessionInfo.LAST_SESSION_INFO_END_KEY); edit.remove(SessionInfo.INTERRUPTION_COUNT_KEY); edit.remove(SessionInfo.SESSION_ID_KEY); edit.apply(); SourceApplicationInfo.Companion.clearSavedSourceApplicationInfoFromDisk(); } } }