package com.facebook.appevents.ondeviceprocessing; import android.os.Bundle; import androidx.core.app.NotificationCompat; import com.facebook.appevents.AppEvent; import com.facebook.appevents.eventdeactivation.EventDeactivationManager; import com.facebook.appevents.ondeviceprocessing.RemoteServiceWrapper; import com.facebook.internal.FetchedAppSettings; import com.facebook.internal.FetchedAppSettingsManager; import com.facebook.internal.Utility; import com.facebook.internal.instrument.crashshield.CrashShieldHandler; import java.util.Collection; import java.util.List; import kotlin.collections.CollectionsKt___CollectionsKt; import kotlin.jvm.internal.Intrinsics; import org.json.JSONArray; /* loaded from: classes2.dex */ public final class RemoteServiceParametersHelper { public static final RemoteServiceParametersHelper INSTANCE = new RemoteServiceParametersHelper(); private static final String TAG = RemoteServiceWrapper.class.getSimpleName(); private RemoteServiceParametersHelper() { } public static final Bundle buildEventsBundle(RemoteServiceWrapper.EventType eventType, String applicationId, List appEvents) { if (CrashShieldHandler.isObjectCrashing(RemoteServiceParametersHelper.class)) { return null; } try { Intrinsics.checkNotNullParameter(eventType, "eventType"); Intrinsics.checkNotNullParameter(applicationId, "applicationId"); Intrinsics.checkNotNullParameter(appEvents, "appEvents"); Bundle bundle = new Bundle(); bundle.putString(NotificationCompat.CATEGORY_EVENT, eventType.toString()); bundle.putString("app_id", applicationId); if (RemoteServiceWrapper.EventType.CUSTOM_APP_EVENTS == eventType) { JSONArray buildEventsJson = INSTANCE.buildEventsJson(appEvents, applicationId); if (buildEventsJson.length() == 0) { return null; } bundle.putString("custom_events", buildEventsJson.toString()); } return bundle; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, RemoteServiceParametersHelper.class); return null; } } private final JSONArray buildEventsJson(List list, String str) { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { JSONArray jSONArray = new JSONArray(); List mutableList = CollectionsKt___CollectionsKt.toMutableList((Collection) list); EventDeactivationManager.processEvents(mutableList); boolean includeImplicitEvents = includeImplicitEvents(str); for (AppEvent appEvent : mutableList) { if (appEvent.isChecksumValid()) { if (!(!appEvent.isImplicit())) { if (appEvent.isImplicit() && includeImplicitEvents) { } } jSONArray.put(appEvent.getJsonObject()); } else { Utility utility = Utility.INSTANCE; Utility.logd(TAG, Intrinsics.stringPlus("Event with invalid checksum: ", appEvent)); } } return jSONArray; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return null; } } private final boolean includeImplicitEvents(String str) { if (CrashShieldHandler.isObjectCrashing(this)) { return false; } try { FetchedAppSettings queryAppSettings = FetchedAppSettingsManager.queryAppSettings(str, false); if (queryAppSettings != null) { return queryAppSettings.supportsImplicitLogging(); } return false; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return false; } } }