package com.facebook.appevents.ondeviceprocessing; import android.content.Context; import android.content.SharedPreferences; import androidx.annotation.RestrictTo; import com.facebook.FacebookSdk; import com.facebook.appevents.AppEvent; import com.facebook.appevents.AppEventsConstants; import com.facebook.internal.Utility; import com.facebook.internal.instrument.crashshield.CrashShieldHandler; import java.util.Set; import kotlin.collections.CollectionsKt__CollectionsJVMKt; import kotlin.collections.SetsKt__SetsKt; import kotlin.jvm.internal.Intrinsics; @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) /* loaded from: classes2.dex */ public final class OnDeviceProcessingManager { private static final Set ALLOWED_IMPLICIT_EVENTS; public static final OnDeviceProcessingManager INSTANCE = new OnDeviceProcessingManager(); private OnDeviceProcessingManager() { } static { Set of; of = SetsKt__SetsKt.setOf((Object[]) new String[]{AppEventsConstants.EVENT_NAME_PURCHASED, AppEventsConstants.EVENT_NAME_START_TRIAL, AppEventsConstants.EVENT_NAME_SUBSCRIBE}); ALLOWED_IMPLICIT_EVENTS = of; } public static final boolean isOnDeviceProcessingEnabled() { if (CrashShieldHandler.isObjectCrashing(OnDeviceProcessingManager.class)) { return false; } try { if (FacebookSdk.getLimitEventAndDataUsage(FacebookSdk.getApplicationContext()) || Utility.isDataProcessingRestricted()) { return false; } return RemoteServiceWrapper.isServiceAvailable(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, OnDeviceProcessingManager.class); return false; } } public static final void sendInstallEventAsync(final String str, final String str2) { if (CrashShieldHandler.isObjectCrashing(OnDeviceProcessingManager.class)) { return; } try { final Context applicationContext = FacebookSdk.getApplicationContext(); if (applicationContext == null || str == null || str2 == null) { return; } FacebookSdk.getExecutor().execute(new Runnable() { // from class: com.facebook.appevents.ondeviceprocessing.OnDeviceProcessingManager$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { OnDeviceProcessingManager.m520sendInstallEventAsync$lambda0(applicationContext, str2, str); } }); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, OnDeviceProcessingManager.class); } } /* JADX INFO: Access modifiers changed from: private */ /* renamed from: sendInstallEventAsync$lambda-0, reason: not valid java name */ public static final void m520sendInstallEventAsync$lambda0(Context context, String str, String str2) { if (CrashShieldHandler.isObjectCrashing(OnDeviceProcessingManager.class)) { return; } try { Intrinsics.checkNotNullParameter(context, "$context"); SharedPreferences sharedPreferences = context.getSharedPreferences(str, 0); String stringPlus = Intrinsics.stringPlus(str2, "pingForOnDevice"); if (sharedPreferences.getLong(stringPlus, 0L) == 0) { RemoteServiceWrapper.sendInstallEvent(str2); SharedPreferences.Editor edit = sharedPreferences.edit(); edit.putLong(stringPlus, System.currentTimeMillis()); edit.apply(); } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, OnDeviceProcessingManager.class); } } public static final void sendCustomEventAsync(final String applicationId, final AppEvent event) { if (CrashShieldHandler.isObjectCrashing(OnDeviceProcessingManager.class)) { return; } try { Intrinsics.checkNotNullParameter(applicationId, "applicationId"); Intrinsics.checkNotNullParameter(event, "event"); if (INSTANCE.isEventEligibleForOnDeviceProcessing(event)) { FacebookSdk.getExecutor().execute(new Runnable() { // from class: com.facebook.appevents.ondeviceprocessing.OnDeviceProcessingManager$$ExternalSyntheticLambda1 @Override // java.lang.Runnable public final void run() { OnDeviceProcessingManager.m519sendCustomEventAsync$lambda1(applicationId, event); } }); } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, OnDeviceProcessingManager.class); } } /* JADX INFO: Access modifiers changed from: private */ /* renamed from: sendCustomEventAsync$lambda-1, reason: not valid java name */ public static final void m519sendCustomEventAsync$lambda1(String applicationId, AppEvent event) { if (CrashShieldHandler.isObjectCrashing(OnDeviceProcessingManager.class)) { return; } try { Intrinsics.checkNotNullParameter(applicationId, "$applicationId"); Intrinsics.checkNotNullParameter(event, "$event"); RemoteServiceWrapper remoteServiceWrapper = RemoteServiceWrapper.INSTANCE; RemoteServiceWrapper.sendCustomEvents(applicationId, CollectionsKt__CollectionsJVMKt.listOf(event)); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, OnDeviceProcessingManager.class); } } private final boolean isEventEligibleForOnDeviceProcessing(AppEvent appEvent) { if (CrashShieldHandler.isObjectCrashing(this)) { return false; } try { return (appEvent.isImplicit() ^ true) || (appEvent.isImplicit() && ALLOWED_IMPLICIT_EVENTS.contains(appEvent.getName())); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return false; } } }