- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
150 lines
5.8 KiB
Java
150 lines
5.8 KiB
Java
package com.facebook;
|
|
|
|
import android.content.SharedPreferences;
|
|
import android.os.Bundle;
|
|
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class AccessTokenCache {
|
|
public static final String CACHED_ACCESS_TOKEN_KEY = "com.facebook.AccessTokenManager.CachedAccessToken";
|
|
public static final Companion Companion = new Companion(null);
|
|
private final SharedPreferences sharedPreferences;
|
|
private final SharedPreferencesTokenCachingStrategyFactory tokenCachingStrategyFactory;
|
|
private LegacyTokenHelper tokenCachingStrategyField;
|
|
|
|
public AccessTokenCache(SharedPreferences sharedPreferences, SharedPreferencesTokenCachingStrategyFactory tokenCachingStrategyFactory) {
|
|
Intrinsics.checkNotNullParameter(sharedPreferences, "sharedPreferences");
|
|
Intrinsics.checkNotNullParameter(tokenCachingStrategyFactory, "tokenCachingStrategyFactory");
|
|
this.sharedPreferences = sharedPreferences;
|
|
this.tokenCachingStrategyFactory = tokenCachingStrategyFactory;
|
|
}
|
|
|
|
private final LegacyTokenHelper getTokenCachingStrategy() {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return null;
|
|
}
|
|
try {
|
|
if (this.tokenCachingStrategyField == null) {
|
|
synchronized (this) {
|
|
try {
|
|
if (this.tokenCachingStrategyField == null) {
|
|
this.tokenCachingStrategyField = this.tokenCachingStrategyFactory.create();
|
|
}
|
|
Unit unit = Unit.INSTANCE;
|
|
} finally {
|
|
}
|
|
}
|
|
}
|
|
LegacyTokenHelper legacyTokenHelper = this.tokenCachingStrategyField;
|
|
if (legacyTokenHelper != null) {
|
|
return legacyTokenHelper;
|
|
}
|
|
throw new IllegalStateException("Required value was null.".toString());
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* 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 AccessTokenCache() {
|
|
/*
|
|
r3 = this;
|
|
android.content.Context r0 = com.facebook.FacebookSdk.getApplicationContext()
|
|
java.lang.String r1 = "com.facebook.AccessTokenManager.SharedPreferences"
|
|
r2 = 0
|
|
android.content.SharedPreferences r0 = r0.getSharedPreferences(r1, r2)
|
|
java.lang.String r1 = "FacebookSdk.getApplicationContext()\n .getSharedPreferences(\n AccessTokenManager.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)"
|
|
kotlin.jvm.internal.Intrinsics.checkNotNullExpressionValue(r0, r1)
|
|
com.facebook.AccessTokenCache$SharedPreferencesTokenCachingStrategyFactory r1 = new com.facebook.AccessTokenCache$SharedPreferencesTokenCachingStrategyFactory
|
|
r1.<init>()
|
|
r3.<init>(r0, r1)
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.facebook.AccessTokenCache.<init>():void");
|
|
}
|
|
|
|
public final AccessToken load() {
|
|
if (hasCachedAccessToken()) {
|
|
return getCachedAccessToken();
|
|
}
|
|
if (!shouldCheckLegacyToken()) {
|
|
return null;
|
|
}
|
|
AccessToken legacyAccessToken = getLegacyAccessToken();
|
|
if (legacyAccessToken == null) {
|
|
return legacyAccessToken;
|
|
}
|
|
save(legacyAccessToken);
|
|
getTokenCachingStrategy().clear();
|
|
return legacyAccessToken;
|
|
}
|
|
|
|
public final void save(AccessToken accessToken) {
|
|
Intrinsics.checkNotNullParameter(accessToken, "accessToken");
|
|
try {
|
|
this.sharedPreferences.edit().putString(CACHED_ACCESS_TOKEN_KEY, accessToken.toJSONObject$facebook_core_release().toString()).apply();
|
|
} catch (JSONException unused) {
|
|
}
|
|
}
|
|
|
|
public final void clear() {
|
|
this.sharedPreferences.edit().remove(CACHED_ACCESS_TOKEN_KEY).apply();
|
|
if (shouldCheckLegacyToken()) {
|
|
getTokenCachingStrategy().clear();
|
|
}
|
|
}
|
|
|
|
private final boolean hasCachedAccessToken() {
|
|
return this.sharedPreferences.contains(CACHED_ACCESS_TOKEN_KEY);
|
|
}
|
|
|
|
private final AccessToken getCachedAccessToken() {
|
|
String string = this.sharedPreferences.getString(CACHED_ACCESS_TOKEN_KEY, null);
|
|
if (string == null) {
|
|
return null;
|
|
}
|
|
try {
|
|
return AccessToken.Companion.createFromJSONObject$facebook_core_release(new JSONObject(string));
|
|
} catch (JSONException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private final boolean shouldCheckLegacyToken() {
|
|
return FacebookSdk.isLegacyTokenUpgradeSupported();
|
|
}
|
|
|
|
private final AccessToken getLegacyAccessToken() {
|
|
Bundle load = getTokenCachingStrategy().load();
|
|
if (load == null || !LegacyTokenHelper.Companion.hasTokenInformation(load)) {
|
|
return null;
|
|
}
|
|
return AccessToken.Companion.createFromLegacyCache$facebook_core_release(load);
|
|
}
|
|
|
|
public static final class SharedPreferencesTokenCachingStrategyFactory {
|
|
public final LegacyTokenHelper create() {
|
|
return new LegacyTokenHelper(FacebookSdk.getApplicationContext(), null, 2, null);
|
|
}
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
}
|
|
}
|