package com.facebook.appevents; import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; import android.util.Log; import android.webkit.WebView; import com.facebook.AccessToken; import com.facebook.FacebookException; import com.facebook.FacebookSdk; import com.facebook.LoggingBehavior; import com.facebook.appevents.AppEventsLogger; import com.facebook.appevents.AppEventsLoggerImpl; import com.facebook.appevents.integrity.BlocklistEventsManager; import com.facebook.appevents.integrity.MACARuleMatchingManager; import com.facebook.appevents.integrity.ProtectedModeManager; import com.facebook.appevents.internal.ActivityLifecycleTracker; import com.facebook.appevents.internal.AutomaticAnalyticsLogger; import com.facebook.appevents.internal.Constants; import com.facebook.appevents.ondeviceprocessing.OnDeviceProcessingManager; import com.facebook.internal.AnalyticsEvents; import com.facebook.internal.FeatureManager; import com.facebook.internal.FetchedAppGateKeepersManager; import com.facebook.internal.FetchedAppSettingsManager; import com.facebook.internal.InstallReferrerUtil; import com.facebook.internal.Logger; import com.facebook.internal.Utility; import com.facebook.internal.Validate; import com.facebook.internal.instrument.crashshield.CrashShieldHandler; import csdk.gluads.Consts; import java.math.BigDecimal; import java.util.Currency; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.UUID; import java.util.concurrent.Executor; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import kotlin.Unit; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; import kotlin.text.StringsKt__StringsJVMKt; import kotlin.text.StringsKt__StringsKt; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes2.dex */ public final class AppEventsLoggerImpl { private static final String ACCOUNT_KIT_EVENT_NAME_PREFIX = "fb_ak"; public static final String APP_EVENTS_KILLSWITCH = "app_events_killswitch"; private static final String APP_EVENT_NAME_PUSH_OPENED = "fb_mobile_push_opened"; private static final String APP_EVENT_PREFERENCES = "com.facebook.sdk.appEventPreferences"; private static final String APP_EVENT_PUSH_PARAMETER_ACTION = "fb_push_action"; private static final String APP_EVENT_PUSH_PARAMETER_CAMPAIGN = "fb_push_campaign"; private static final int APP_SUPPORTS_ATTRIBUTION_ID_RECHECK_PERIOD_IN_SECONDS = 86400; public static final Companion Companion = new Companion(null); private static final String PUSH_PAYLOAD_CAMPAIGN_KEY = "campaign"; private static final String PUSH_PAYLOAD_KEY = "fb_push_payload"; private static final String TAG; private static String anonymousAppDeviceGUID; private static ScheduledThreadPoolExecutor backgroundExecutor; private static AppEventsLogger.FlushBehavior flushBehaviorField; private static boolean isActivateAppEventRequested; private static String pushNotificationsRegistrationIdField; private static final Object staticLock; private AccessTokenAppIdPair accessTokenAppId; private final String contextName; public static final void activateApp(Application application, String str) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { Companion.activateApp(application, str); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final void augmentWebView(WebView webView, Context context) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { Companion.augmentWebView(webView, context); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final void functionDEPRECATED(String str) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { Companion.functionDEPRECATED(str); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final Executor getAnalyticsExecutor() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return Companion.getAnalyticsExecutor(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final String getAnonymousAppDeviceGUID(Context context) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return Companion.getAnonymousAppDeviceGUID(context); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final AppEventsLogger.FlushBehavior getFlushBehavior() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return Companion.getFlushBehavior(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final String getInstallReferrer() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return Companion.getInstallReferrer(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final String getPushNotificationsRegistrationId() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return Companion.getPushNotificationsRegistrationId(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final void initializeLib(Context context, String str) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { Companion.initializeLib(context, str); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final void onContextStop() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { Companion.onContextStop(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final void setFlushBehavior(AppEventsLogger.FlushBehavior flushBehavior) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { Companion.setFlushBehavior(flushBehavior); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final void setInstallReferrer(String str) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { Companion.setInstallReferrer(str); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final void setPushNotificationsRegistrationId(String str) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { Companion.setPushNotificationsRegistrationId(str); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public AppEventsLoggerImpl(String activityName, String str, AccessToken accessToken) { Intrinsics.checkNotNullParameter(activityName, "activityName"); Validate.sdkInitialized(); this.contextName = activityName; accessToken = accessToken == null ? AccessToken.Companion.getCurrentAccessToken() : accessToken; if (accessToken == null || accessToken.isExpired() || !(str == null || Intrinsics.areEqual(str, accessToken.getApplicationId()))) { if (str == null) { Utility utility = Utility.INSTANCE; str = Utility.getMetadataApplicationId(FacebookSdk.getApplicationContext()); } if (str != null) { this.accessTokenAppId = new AccessTokenAppIdPair(null, str); } else { throw new IllegalStateException("Required value was null.".toString()); } } else { this.accessTokenAppId = new AccessTokenAppIdPair(accessToken); } Companion.initializeTimersIfNeeded(); } public static final /* synthetic */ String access$getAnonymousAppDeviceGUID$cp() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return anonymousAppDeviceGUID; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final /* synthetic */ ScheduledThreadPoolExecutor access$getBackgroundExecutor$cp() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return backgroundExecutor; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final /* synthetic */ AppEventsLogger.FlushBehavior access$getFlushBehaviorField$cp() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return flushBehaviorField; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final /* synthetic */ String access$getPushNotificationsRegistrationIdField$cp() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return pushNotificationsRegistrationIdField; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final /* synthetic */ Object access$getStaticLock$cp() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return staticLock; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final /* synthetic */ String access$getTAG$cp() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return null; } try { return TAG; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return null; } } public static final /* synthetic */ boolean access$isActivateAppEventRequested$cp() { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return false; } try { return isActivateAppEventRequested; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); return false; } } public static final /* synthetic */ void access$setActivateAppEventRequested$cp(boolean z) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { isActivateAppEventRequested = z; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final /* synthetic */ void access$setAnonymousAppDeviceGUID$cp(String str) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { anonymousAppDeviceGUID = str; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final /* synthetic */ void access$setBackgroundExecutor$cp(ScheduledThreadPoolExecutor scheduledThreadPoolExecutor) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { backgroundExecutor = scheduledThreadPoolExecutor; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final /* synthetic */ void access$setFlushBehaviorField$cp(AppEventsLogger.FlushBehavior flushBehavior) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { flushBehaviorField = flushBehavior; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public static final /* synthetic */ void access$setPushNotificationsRegistrationIdField$cp(String str) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } try { pushNotificationsRegistrationIdField = str; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public AppEventsLoggerImpl(Context context, String str, AccessToken accessToken) { this(Utility.getActivityName(context), str, accessToken); } public final void logEvent(String str) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { logEvent(str, (Bundle) null); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public static /* synthetic */ void logEvent$default(AppEventsLoggerImpl appEventsLoggerImpl, String str, Bundle bundle, int i, Object obj) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } if ((i & 2) != 0) { bundle = null; } try { appEventsLoggerImpl.logEvent(str, bundle); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public final void logEvent(String str, Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { logEvent(str, null, bundle, false, ActivityLifecycleTracker.getCurrentSessionGuid()); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logEvent(String str, double d) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { logEvent(str, d, null); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logEvent(String str, double d, Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { logEvent(str, Double.valueOf(d), bundle, false, ActivityLifecycleTracker.getCurrentSessionGuid()); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logEventFromSE(String str, String str2) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { Bundle bundle = new Bundle(); bundle.putString("_is_suggested_event", "1"); bundle.putString("_button_text", str2); logEvent(str, bundle); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logPurchase(BigDecimal bigDecimal, Currency currency) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { logPurchase(bigDecimal, currency, null); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public static /* synthetic */ void logPurchase$default(AppEventsLoggerImpl appEventsLoggerImpl, BigDecimal bigDecimal, Currency currency, Bundle bundle, int i, Object obj) { if (CrashShieldHandler.isObjectCrashing(AppEventsLoggerImpl.class)) { return; } if ((i & 4) != 0) { bundle = null; } try { appEventsLoggerImpl.logPurchase(bigDecimal, currency, bundle); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, AppEventsLoggerImpl.class); } } public final void logPurchase(BigDecimal bigDecimal, Currency currency, Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (AutomaticAnalyticsLogger.isImplicitPurchaseLoggingEnabled()) { Log.w(TAG, "You are logging purchase events while auto-logging of in-app purchase is enabled in the SDK. Make sure you don't log duplicate events"); } logPurchase(bigDecimal, currency, bundle, false); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logPurchaseImplicitly(BigDecimal bigDecimal, Currency currency, Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { logPurchase(bigDecimal, currency, bundle, true); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logPurchase(BigDecimal bigDecimal, Currency currency, Bundle bundle, boolean z) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (bigDecimal == null) { Companion.notifyDeveloperError("purchaseAmount cannot be null"); return; } if (currency != null) { if (bundle == null) { bundle = new Bundle(); } Bundle bundle2 = bundle; bundle2.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency.getCurrencyCode()); logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, Double.valueOf(bigDecimal.doubleValue()), bundle2, z, ActivityLifecycleTracker.getCurrentSessionGuid()); Companion.eagerFlush(); return; } Companion.notifyDeveloperError("currency cannot be null"); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logPushNotificationOpen(Bundle payload, String str) { String str2; String string; if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { Intrinsics.checkNotNullParameter(payload, "payload"); try { string = payload.getString(PUSH_PAYLOAD_KEY); } catch (JSONException unused) { str2 = null; } if (Utility.isNullOrEmpty(string)) { return; } str2 = new JSONObject(string).getString("campaign"); if (str2 == null) { Logger.Companion.log(LoggingBehavior.DEVELOPER_ERRORS, TAG, "Malformed payload specified for logging a push notification open."); return; } Bundle bundle = new Bundle(); bundle.putString(APP_EVENT_PUSH_PARAMETER_CAMPAIGN, str2); if (str != null) { bundle.putString(APP_EVENT_PUSH_PARAMETER_ACTION, str); } logEvent(APP_EVENT_NAME_PUSH_OPENED, bundle); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logProductItem(String str, AppEventsLogger.ProductAvailability productAvailability, AppEventsLogger.ProductCondition productCondition, String str2, String str3, String str4, String str5, BigDecimal bigDecimal, Currency currency, String str6, String str7, String str8, Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (str == null) { Companion.notifyDeveloperError("itemID cannot be null"); return; } if (productAvailability == null) { Companion.notifyDeveloperError("availability cannot be null"); return; } if (productCondition == null) { Companion.notifyDeveloperError("condition cannot be null"); return; } if (str2 == null) { Companion.notifyDeveloperError("description cannot be null"); return; } if (str3 == null) { Companion.notifyDeveloperError("imageLink cannot be null"); return; } if (str4 == null) { Companion.notifyDeveloperError("link cannot be null"); return; } if (str5 == null) { Companion.notifyDeveloperError("title cannot be null"); return; } if (bigDecimal == null) { Companion.notifyDeveloperError("priceAmount cannot be null"); return; } if (currency == null) { Companion.notifyDeveloperError("currency cannot be null"); return; } if (str6 != null || str7 != null || str8 != null) { if (bundle == null) { bundle = new Bundle(); } bundle.putString(Constants.EVENT_PARAM_PRODUCT_ITEM_ID, str); bundle.putString(Constants.EVENT_PARAM_PRODUCT_AVAILABILITY, productAvailability.name()); bundle.putString(Constants.EVENT_PARAM_PRODUCT_CONDITION, productCondition.name()); bundle.putString(Constants.EVENT_PARAM_PRODUCT_DESCRIPTION, str2); bundle.putString(Constants.EVENT_PARAM_PRODUCT_IMAGE_LINK, str3); bundle.putString(Constants.EVENT_PARAM_PRODUCT_LINK, str4); bundle.putString(Constants.EVENT_PARAM_PRODUCT_TITLE, str5); bundle.putString(Constants.EVENT_PARAM_PRODUCT_PRICE_AMOUNT, bigDecimal.setScale(3, 4).toString()); bundle.putString(Constants.EVENT_PARAM_PRODUCT_PRICE_CURRENCY, currency.getCurrencyCode()); if (str6 != null) { bundle.putString(Constants.EVENT_PARAM_PRODUCT_GTIN, str6); } if (str7 != null) { bundle.putString(Constants.EVENT_PARAM_PRODUCT_MPN, str7); } if (str8 != null) { bundle.putString(Constants.EVENT_PARAM_PRODUCT_BRAND, str8); } logEvent(AppEventsConstants.EVENT_NAME_PRODUCT_CATALOG_UPDATE, bundle); Companion.eagerFlush(); return; } Companion.notifyDeveloperError("Either gtin, mpn or brand is required"); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void flush() { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { AppEventQueue appEventQueue = AppEventQueue.INSTANCE; AppEventQueue.flush(FlushReason.EXPLICIT); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final boolean isValidForAccessToken(AccessToken accessToken) { if (CrashShieldHandler.isObjectCrashing(this)) { return false; } try { Intrinsics.checkNotNullParameter(accessToken, "accessToken"); return Intrinsics.areEqual(this.accessTokenAppId, new AccessTokenAppIdPair(accessToken)); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return false; } } public final void logSdkEvent(String eventName, Double d, Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { Intrinsics.checkNotNullParameter(eventName, "eventName"); if (!StringsKt__StringsJVMKt.startsWith$default(eventName, ACCOUNT_KIT_EVENT_NAME_PREFIX, false, 2, null)) { Log.e(TAG, "logSdkEvent is deprecated and only supports account kit for legacy, please use logEvent instead"); } else if (FacebookSdk.getAutoLogAppEventsEnabled()) { logEvent(eventName, d, bundle, true, ActivityLifecycleTracker.getCurrentSessionGuid()); } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final String getApplicationId() { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { return this.accessTokenAppId.getApplicationId(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return null; } } public final void logEventImplicitly(String str, Double d, Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { logEvent(str, d, bundle, true, ActivityLifecycleTracker.getCurrentSessionGuid()); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logEventImplicitly(String str, BigDecimal bigDecimal, Currency currency, Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (bigDecimal == null || currency == null) { Utility utility = Utility.INSTANCE; Utility.logd(TAG, "purchaseAmount and currency cannot be null"); return; } if (bundle == null) { bundle = new Bundle(); } Bundle bundle2 = bundle; bundle2.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency.getCurrencyCode()); logEvent(str, Double.valueOf(bigDecimal.doubleValue()), bundle2, true, ActivityLifecycleTracker.getCurrentSessionGuid()); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public final void logEvent(String str, Double d, Bundle bundle, boolean z, UUID uuid) { if (CrashShieldHandler.isObjectCrashing(this) || str == null) { return; } try { if (str.length() == 0) { return; } FetchedAppGateKeepersManager fetchedAppGateKeepersManager = FetchedAppGateKeepersManager.INSTANCE; if (FetchedAppGateKeepersManager.getGateKeeperForKey(APP_EVENTS_KILLSWITCH, FacebookSdk.getApplicationId(), false)) { Logger.Companion.log(LoggingBehavior.APP_EVENTS, "AppEvents", "KillSwitch is enabled and fail to log app event: %s", str); return; } if (BlocklistEventsManager.isInBlocklist(str)) { return; } try { MACARuleMatchingManager.processParameters(bundle, str); ProtectedModeManager.processParametersForProtectedMode(bundle); Companion.logEvent(new AppEvent(this.contextName, str, d, bundle, z, ActivityLifecycleTracker.isInBackground(), uuid), this.accessTokenAppId); } catch (FacebookException e) { Logger.Companion.log(LoggingBehavior.APP_EVENTS, "AppEvents", "Invalid app event: %s", e.toString()); } catch (JSONException e2) { Logger.Companion.log(LoggingBehavior.APP_EVENTS, "AppEvents", "JSON encoding for app event failed: '%s'", e2.toString()); } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public final AppEventsLogger.FlushBehavior getFlushBehavior() { AppEventsLogger.FlushBehavior access$getFlushBehaviorField$cp; synchronized (AppEventsLoggerImpl.access$getStaticLock$cp()) { access$getFlushBehaviorField$cp = AppEventsLoggerImpl.access$getFlushBehaviorField$cp(); } return access$getFlushBehaviorField$cp; } public final void setFlushBehavior(AppEventsLogger.FlushBehavior flushBehavior) { Intrinsics.checkNotNullParameter(flushBehavior, "flushBehavior"); synchronized (AppEventsLoggerImpl.access$getStaticLock$cp()) { AppEventsLoggerImpl.access$setFlushBehaviorField$cp(flushBehavior); Unit unit = Unit.INSTANCE; } } public final String getPushNotificationsRegistrationId() { String access$getPushNotificationsRegistrationIdField$cp; synchronized (AppEventsLoggerImpl.access$getStaticLock$cp()) { access$getPushNotificationsRegistrationIdField$cp = AppEventsLoggerImpl.access$getPushNotificationsRegistrationIdField$cp(); } return access$getPushNotificationsRegistrationIdField$cp; } public final void setPushNotificationsRegistrationId(String str) { synchronized (AppEventsLoggerImpl.access$getStaticLock$cp()) { try { Utility utility = Utility.INSTANCE; if (!Utility.stringsEqualOrEmpty(AppEventsLoggerImpl.access$getPushNotificationsRegistrationIdField$cp(), str)) { AppEventsLoggerImpl.access$setPushNotificationsRegistrationIdField$cp(str); AppEventsLoggerImpl appEventsLoggerImpl = new AppEventsLoggerImpl(FacebookSdk.getApplicationContext(), (String) null, (AccessToken) null); appEventsLoggerImpl.logEvent(AppEventsConstants.EVENT_NAME_PUSH_TOKEN_OBTAINED); if (AppEventsLoggerImpl.Companion.getFlushBehavior() != AppEventsLogger.FlushBehavior.EXPLICIT_ONLY) { appEventsLoggerImpl.flush(); } } Unit unit = Unit.INSTANCE; } catch (Throwable th) { throw th; } } } public final void activateApp(Application application, String str) { Intrinsics.checkNotNullParameter(application, "application"); if (!FacebookSdk.isInitialized()) { throw new FacebookException("The Facebook sdk must be initialized before calling activateApp"); } AnalyticsUserIDStore.initStore(); UserDataStore.initStore(); if (str == null) { str = FacebookSdk.getApplicationId(); } FacebookSdk.publishInstallAsync(application, str); ActivityLifecycleTracker.startTracking(application, str); } public final void functionDEPRECATED(String extraMsg) { Intrinsics.checkNotNullParameter(extraMsg, "extraMsg"); Log.w(AppEventsLoggerImpl.access$getTAG$cp(), Intrinsics.stringPlus("This function is deprecated. ", extraMsg)); } public final void initializeLib(final Context context, String str) { Intrinsics.checkNotNullParameter(context, "context"); if (FacebookSdk.getAutoLogAppEventsEnabled()) { final AppEventsLoggerImpl appEventsLoggerImpl = new AppEventsLoggerImpl(context, str, (AccessToken) null); ScheduledThreadPoolExecutor access$getBackgroundExecutor$cp = AppEventsLoggerImpl.access$getBackgroundExecutor$cp(); if (access$getBackgroundExecutor$cp == null) { throw new IllegalStateException("Required value was null.".toString()); } access$getBackgroundExecutor$cp.execute(new Runnable() { // from class: com.facebook.appevents.AppEventsLoggerImpl$Companion$$ExternalSyntheticLambda1 @Override // java.lang.Runnable public final void run() { AppEventsLoggerImpl.Companion.m457initializeLib$lambda4(context, appEventsLoggerImpl); } }); } } /* JADX INFO: Access modifiers changed from: private */ /* renamed from: initializeLib$lambda-4, reason: not valid java name */ public static final void m457initializeLib$lambda4(Context context, AppEventsLoggerImpl logger) { Intrinsics.checkNotNullParameter(context, "$context"); Intrinsics.checkNotNullParameter(logger, "$logger"); Bundle bundle = new Bundle(); String[] strArr = {"com.facebook.core.Core", "com.facebook.login.Login", "com.facebook.share.Share", "com.facebook.places.Places", "com.facebook.messenger.Messenger", "com.facebook.applinks.AppLinks", "com.facebook.marketing.Marketing", "com.facebook.gamingservices.GamingServices", "com.facebook.all.All", "com.android.billingclient.api.BillingClient", "com.android.vending.billing.IInAppBillingService"}; String[] strArr2 = {"core_lib_included", "login_lib_included", "share_lib_included", "places_lib_included", "messenger_lib_included", "applinks_lib_included", "marketing_lib_included", "gamingservices_lib_included", "all_lib_included", "billing_client_lib_included", "billing_service_lib_included"}; int i = 0; int i2 = 0; while (true) { int i3 = i + 1; String str = strArr[i]; String str2 = strArr2[i]; try { Class.forName(str); bundle.putInt(str2, 1); i2 |= 1 << i; } catch (ClassNotFoundException unused) { } if (i3 > 10) { break; } else { i = i3; } } SharedPreferences sharedPreferences = context.getSharedPreferences("com.facebook.sdk.appEventPreferences", 0); if (sharedPreferences.getInt("kitsBitmask", 0) != i2) { sharedPreferences.edit().putInt("kitsBitmask", i2).apply(); logger.logEventImplicitly(AnalyticsEvents.EVENT_SDK_INITIALIZE, null, bundle); } } public final void onContextStop() { AppEventQueue.persistToDisk(); } public final String getInstallReferrer() { InstallReferrerUtil installReferrerUtil = InstallReferrerUtil.INSTANCE; InstallReferrerUtil.tryUpdateReferrerInfo(new InstallReferrerUtil.Callback() { // from class: com.facebook.appevents.AppEventsLoggerImpl$Companion$getInstallReferrer$1 @Override // com.facebook.internal.InstallReferrerUtil.Callback public void onReceiveReferrerUrl(String str) { AppEventsLoggerImpl.Companion.setInstallReferrer(str); } }); return FacebookSdk.getApplicationContext().getSharedPreferences("com.facebook.sdk.appEventPreferences", 0).getString("install_referrer", null); } public final void setInstallReferrer(String str) { SharedPreferences sharedPreferences = FacebookSdk.getApplicationContext().getSharedPreferences("com.facebook.sdk.appEventPreferences", 0); if (str != null) { sharedPreferences.edit().putString("install_referrer", str).apply(); } } public final void augmentWebView(WebView webView, Context context) { List split$default; Intrinsics.checkNotNullParameter(webView, "webView"); String RELEASE = Build.VERSION.RELEASE; Intrinsics.checkNotNullExpressionValue(RELEASE, "RELEASE"); split$default = StringsKt__StringsKt.split$default((CharSequence) RELEASE, new String[]{Consts.STRING_PERIOD}, false, 0, 6, (Object) null); Object[] array = split$default.toArray(new String[0]); if (array == null) { throw new NullPointerException("null cannot be cast to non-null type kotlin.Array"); } String[] strArr = (String[]) array; int parseInt = (strArr.length == 0) ^ true ? Integer.parseInt(strArr[0]) : 0; int parseInt2 = strArr.length > 1 ? Integer.parseInt(strArr[1]) : 0; if (parseInt < 4 || (parseInt == 4 && parseInt2 <= 1)) { Logger.Companion.log(LoggingBehavior.DEVELOPER_ERRORS, AppEventsLoggerImpl.access$getTAG$cp(), "augmentWebView is only available for Android SDK version >= 17 on devices running Android >= 4.2"); } else { webView.addJavascriptInterface(new FacebookSDKJSInterface(context), Intrinsics.stringPlus("fbmq_", FacebookSdk.getApplicationId())); } } /* JADX INFO: Access modifiers changed from: private */ public final void initializeTimersIfNeeded() { synchronized (AppEventsLoggerImpl.access$getStaticLock$cp()) { if (AppEventsLoggerImpl.access$getBackgroundExecutor$cp() != null) { return; } AppEventsLoggerImpl.access$setBackgroundExecutor$cp(new ScheduledThreadPoolExecutor(1)); Unit unit = Unit.INSTANCE; Runnable runnable = new Runnable() { // from class: com.facebook.appevents.AppEventsLoggerImpl$Companion$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { AppEventsLoggerImpl.Companion.m458initializeTimersIfNeeded$lambda6(); } }; ScheduledThreadPoolExecutor access$getBackgroundExecutor$cp = AppEventsLoggerImpl.access$getBackgroundExecutor$cp(); if (access$getBackgroundExecutor$cp == null) { throw new IllegalStateException("Required value was null.".toString()); } access$getBackgroundExecutor$cp.scheduleAtFixedRate(runnable, 0L, 86400L, TimeUnit.SECONDS); } } /* JADX INFO: Access modifiers changed from: private */ /* renamed from: initializeTimersIfNeeded$lambda-6, reason: not valid java name */ public static final void m458initializeTimersIfNeeded$lambda6() { HashSet hashSet = new HashSet(); Iterator it = AppEventQueue.getKeySet().iterator(); while (it.hasNext()) { hashSet.add(it.next().getApplicationId()); } Iterator it2 = hashSet.iterator(); while (it2.hasNext()) { FetchedAppSettingsManager.queryAppSettings((String) it2.next(), true); } } /* JADX INFO: Access modifiers changed from: private */ public final void logEvent(AppEvent appEvent, AccessTokenAppIdPair accessTokenAppIdPair) { AppEventQueue.add(accessTokenAppIdPair, appEvent); FeatureManager featureManager = FeatureManager.INSTANCE; if (FeatureManager.isEnabled(FeatureManager.Feature.OnDevicePostInstallEventProcessing) && OnDeviceProcessingManager.isOnDeviceProcessingEnabled()) { OnDeviceProcessingManager.sendCustomEventAsync(accessTokenAppIdPair.getApplicationId(), appEvent); } if (appEvent.getIsImplicit() || AppEventsLoggerImpl.access$isActivateAppEventRequested$cp()) { return; } if (Intrinsics.areEqual(appEvent.getName(), AppEventsConstants.EVENT_NAME_ACTIVATED_APP)) { AppEventsLoggerImpl.access$setActivateAppEventRequested$cp(true); } else { Logger.Companion.log(LoggingBehavior.APP_EVENTS, "AppEvents", "Warning: Please call AppEventsLogger.activateApp(...)from the long-lived activity's onResume() methodbefore logging other app events."); } } public final void eagerFlush() { if (getFlushBehavior() != AppEventsLogger.FlushBehavior.EXPLICIT_ONLY) { AppEventQueue appEventQueue = AppEventQueue.INSTANCE; AppEventQueue.flush(FlushReason.EAGER_FLUSHING_EVENT); } } /* JADX INFO: Access modifiers changed from: private */ public final void notifyDeveloperError(String str) { Logger.Companion.log(LoggingBehavior.DEVELOPER_ERRORS, "AppEvents", str); } public final Executor getAnalyticsExecutor() { if (AppEventsLoggerImpl.access$getBackgroundExecutor$cp() == null) { initializeTimersIfNeeded(); } ScheduledThreadPoolExecutor access$getBackgroundExecutor$cp = AppEventsLoggerImpl.access$getBackgroundExecutor$cp(); if (access$getBackgroundExecutor$cp != null) { return access$getBackgroundExecutor$cp; } throw new IllegalStateException("Required value was null.".toString()); } public final String getAnonymousAppDeviceGUID(Context context) { Intrinsics.checkNotNullParameter(context, "context"); if (AppEventsLoggerImpl.access$getAnonymousAppDeviceGUID$cp() == null) { synchronized (AppEventsLoggerImpl.access$getStaticLock$cp()) { try { if (AppEventsLoggerImpl.access$getAnonymousAppDeviceGUID$cp() == null) { AppEventsLoggerImpl.access$setAnonymousAppDeviceGUID$cp(context.getSharedPreferences("com.facebook.sdk.appEventPreferences", 0).getString("anonymousAppDeviceGUID", null)); if (AppEventsLoggerImpl.access$getAnonymousAppDeviceGUID$cp() == null) { UUID randomUUID = UUID.randomUUID(); Intrinsics.checkNotNullExpressionValue(randomUUID, "randomUUID()"); AppEventsLoggerImpl.access$setAnonymousAppDeviceGUID$cp(Intrinsics.stringPlus("XZ", randomUUID)); context.getSharedPreferences("com.facebook.sdk.appEventPreferences", 0).edit().putString("anonymousAppDeviceGUID", AppEventsLoggerImpl.access$getAnonymousAppDeviceGUID$cp()).apply(); } } Unit unit = Unit.INSTANCE; } catch (Throwable th) { throw th; } } } String access$getAnonymousAppDeviceGUID$cp = AppEventsLoggerImpl.access$getAnonymousAppDeviceGUID$cp(); if (access$getAnonymousAppDeviceGUID$cp != null) { return access$getAnonymousAppDeviceGUID$cp; } throw new IllegalStateException("Required value was null.".toString()); } } static { String canonicalName = AppEventsLoggerImpl.class.getCanonicalName(); if (canonicalName == null) { canonicalName = "com.facebook.appevents.AppEventsLoggerImpl"; } TAG = canonicalName; flushBehaviorField = AppEventsLogger.FlushBehavior.AUTO; staticLock = new Object(); } }