package com.facebook; import android.content.Intent; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.facebook.internal.Utility; import com.ironsource.f5; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes2.dex */ public final class ProfileManager { public static final String ACTION_CURRENT_PROFILE_CHANGED = "com.facebook.sdk.ACTION_CURRENT_PROFILE_CHANGED"; public static final Companion Companion = new Companion(null); public static final String EXTRA_NEW_PROFILE = "com.facebook.sdk.EXTRA_NEW_PROFILE"; public static final String EXTRA_OLD_PROFILE = "com.facebook.sdk.EXTRA_OLD_PROFILE"; private static volatile ProfileManager instance; private Profile currentProfileField; private final LocalBroadcastManager localBroadcastManager; private final ProfileCache profileCache; public static final synchronized ProfileManager getInstance() { ProfileManager companion; synchronized (ProfileManager.class) { companion = Companion.getInstance(); } return companion; } public final Profile getCurrentProfile() { return this.currentProfileField; } public ProfileManager(LocalBroadcastManager localBroadcastManager, ProfileCache profileCache) { Intrinsics.checkNotNullParameter(localBroadcastManager, "localBroadcastManager"); Intrinsics.checkNotNullParameter(profileCache, "profileCache"); this.localBroadcastManager = localBroadcastManager; this.profileCache = profileCache; } public final void setCurrentProfile(Profile profile) { setCurrentProfile(profile, true); } public final boolean loadCurrentProfile() { Profile load = this.profileCache.load(); if (load == null) { return false; } setCurrentProfile(load, false); return true; } private final void setCurrentProfile(Profile profile, boolean z) { Profile profile2 = this.currentProfileField; this.currentProfileField = profile; if (z) { if (profile != null) { this.profileCache.save(profile); } else { this.profileCache.clear(); } } if (Utility.areObjectsEqual(profile2, profile)) { return; } sendCurrentProfileChangedBroadcast(profile2, profile); } private final void sendCurrentProfileChangedBroadcast(Profile profile, Profile profile2) { Intent intent = new Intent(ACTION_CURRENT_PROFILE_CHANGED); intent.putExtra(EXTRA_OLD_PROFILE, profile); intent.putExtra(EXTRA_NEW_PROFILE, profile2); this.localBroadcastManager.sendBroadcast(intent); } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public final synchronized ProfileManager getInstance() { ProfileManager profileManager; try { if (ProfileManager.instance == null) { LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(FacebookSdk.getApplicationContext()); Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(applicationContext)"); ProfileManager.instance = new ProfileManager(localBroadcastManager, new ProfileCache()); } profileManager = ProfileManager.instance; if (profileManager == null) { Intrinsics.throwUninitializedPropertyAccessException(f5.o); throw null; } } catch (Throwable th) { throw th; } return profileManager; } } }