package com.facebook; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.facebook.internal.Utility; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes2.dex */ public final class AuthenticationTokenManager { public static final String ACTION_CURRENT_AUTHENTICATION_TOKEN_CHANGED = "com.facebook.sdk.ACTION_CURRENT_AUTHENTICATION_TOKEN_CHANGED"; public static final Companion Companion = new Companion(null); public static final String EXTRA_NEW_AUTHENTICATION_TOKEN = "com.facebook.sdk.EXTRA_NEW_AUTHENTICATION_TOKEN"; public static final String EXTRA_OLD_AUTHENTICATION_TOKEN = "com.facebook.sdk.EXTRA_OLD_AUTHENTICATION_TOKEN"; public static final String SHARED_PREFERENCES_NAME = "com.facebook.AuthenticationTokenManager.SharedPreferences"; public static final String TAG = "AuthenticationTokenManager"; private static AuthenticationTokenManager instanceField; private final AuthenticationTokenCache authenticationTokenCache; private AuthenticationToken currentAuthenticationTokenField; private final LocalBroadcastManager localBroadcastManager; public static final class CurrentAuthenticationTokenChangedBroadcastReceiver extends BroadcastReceiver { @Override // android.content.BroadcastReceiver public void onReceive(Context context, Intent intent) { Intrinsics.checkNotNullParameter(context, "context"); Intrinsics.checkNotNullParameter(intent, "intent"); } } public static final AuthenticationTokenManager getInstance() { return Companion.getInstance(); } public final AuthenticationToken getCurrentAuthenticationToken() { return this.currentAuthenticationTokenField; } public AuthenticationTokenManager(LocalBroadcastManager localBroadcastManager, AuthenticationTokenCache authenticationTokenCache) { Intrinsics.checkNotNullParameter(localBroadcastManager, "localBroadcastManager"); Intrinsics.checkNotNullParameter(authenticationTokenCache, "authenticationTokenCache"); this.localBroadcastManager = localBroadcastManager; this.authenticationTokenCache = authenticationTokenCache; } public final void setCurrentAuthenticationToken(AuthenticationToken authenticationToken) { setCurrentAuthenticationToken(authenticationToken, true); } public final boolean loadCurrentAuthenticationToken() { AuthenticationToken load = this.authenticationTokenCache.load(); if (load == null) { return false; } setCurrentAuthenticationToken(load, false); return true; } public final void currentAuthenticationTokenChanged() { sendCurrentAuthenticationTokenChangedBroadcastIntent(getCurrentAuthenticationToken(), getCurrentAuthenticationToken()); } private final void setCurrentAuthenticationToken(AuthenticationToken authenticationToken, boolean z) { AuthenticationToken currentAuthenticationToken = getCurrentAuthenticationToken(); this.currentAuthenticationTokenField = authenticationToken; if (z) { if (authenticationToken != null) { this.authenticationTokenCache.save(authenticationToken); } else { this.authenticationTokenCache.clear(); Utility utility = Utility.INSTANCE; Utility.clearFacebookCookies(FacebookSdk.getApplicationContext()); } } if (Utility.areObjectsEqual(currentAuthenticationToken, authenticationToken)) { return; } sendCurrentAuthenticationTokenChangedBroadcastIntent(currentAuthenticationToken, authenticationToken); } private final void sendCurrentAuthenticationTokenChangedBroadcastIntent(AuthenticationToken authenticationToken, AuthenticationToken authenticationToken2) { Intent intent = new Intent(FacebookSdk.getApplicationContext(), (Class) CurrentAuthenticationTokenChangedBroadcastReceiver.class); intent.setAction(ACTION_CURRENT_AUTHENTICATION_TOKEN_CHANGED); intent.putExtra(EXTRA_OLD_AUTHENTICATION_TOKEN, authenticationToken); intent.putExtra(EXTRA_NEW_AUTHENTICATION_TOKEN, authenticationToken2); this.localBroadcastManager.sendBroadcast(intent); } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public final AuthenticationTokenManager getInstance() { AuthenticationTokenManager authenticationTokenManager; AuthenticationTokenManager authenticationTokenManager2 = AuthenticationTokenManager.instanceField; if (authenticationTokenManager2 != null) { return authenticationTokenManager2; } synchronized (this) { authenticationTokenManager = AuthenticationTokenManager.instanceField; if (authenticationTokenManager == null) { LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(FacebookSdk.getApplicationContext()); Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(applicationContext)"); AuthenticationTokenManager authenticationTokenManager3 = new AuthenticationTokenManager(localBroadcastManager, new AuthenticationTokenCache()); AuthenticationTokenManager.instanceField = authenticationTokenManager3; authenticationTokenManager = authenticationTokenManager3; } } return authenticationTokenManager; } } }