package com.facebook.appevents.integrity; import android.os.Bundle; import com.applovin.sdk.AppLovinEventParameters; import com.facebook.FacebookSdk; import com.facebook.appevents.AppEventsConstants; import com.facebook.appevents.internal.Constants; import com.facebook.internal.FetchedAppSettings; import com.facebook.internal.FetchedAppSettingsManager; import com.facebook.internal.instrument.crashshield.CrashShieldHandler; import com.ironsource.v8; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import kotlin.Lazy; import kotlin.LazyKt__LazyJVMKt; import kotlin.collections.SetsKt__SetsKt; import kotlin.jvm.functions.Function0; import kotlin.jvm.internal.Intrinsics; import org.json.JSONArray; /* loaded from: classes2.dex */ public final class ProtectedModeManager { public static final ProtectedModeManager INSTANCE = new ProtectedModeManager(); private static final String PROTECTED_MODE_IS_APPLIED_KEY = "pm"; private static final String PROTECTED_MODE_IS_APPLIED_VALUE = "1"; private static final Lazy defaultStandardParameterNames$delegate; private static boolean enabled; private static HashSet standardParams; private ProtectedModeManager() { } static { Lazy lazy; lazy = LazyKt__LazyJVMKt.lazy(new Function0() { // from class: com.facebook.appevents.integrity.ProtectedModeManager$defaultStandardParameterNames$2 @Override // kotlin.jvm.functions.Function0 public final HashSet invoke() { HashSet hashSetOf; hashSetOf = SetsKt__SetsKt.hashSetOf("_currency", AppEventsConstants.EVENT_PARAM_VALUE_TO_SUM, "fb_availability", "fb_body_style", "fb_checkin_date", "fb_checkout_date", "fb_city", "fb_condition_of_vehicle", "fb_content_category", "fb_content_ids", "fb_content_name", AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "fb_contents", "fb_country", AppEventsConstants.EVENT_PARAM_CURRENCY, "fb_delivery_category", "fb_departing_arrival_date", "fb_departing_departure_date", "fb_destination_airport", "fb_destination_ids", "fb_dma_code", "fb_drivetrain", "fb_exterior_color", "fb_fuel_type", "fb_hotel_score", "fb_interior_color", "fb_lease_end_date", "fb_lease_start_date", "fb_listing_type", "fb_make", "fb_mileage.unit", "fb_mileage.value", "fb_model", "fb_neighborhood", "fb_num_adults", "fb_num_children", "fb_num_infants", AppEventsConstants.EVENT_PARAM_NUM_ITEMS, AppEventsConstants.EVENT_PARAM_ORDER_ID, "fb_origin_airport", "fb_postal_code", "fb_predicted_ltv", "fb_preferred_baths_range", "fb_preferred_beds_range", "fb_preferred_neighborhoods", "fb_preferred_num_stops", "fb_preferred_price_range", "fb_preferred_star_ratings", "fb_price", "fb_property_type", "fb_region", "fb_returning_arrival_date", "fb_returning_departure_date", AppEventsConstants.EVENT_PARAM_SEARCH_STRING, "fb_state_of_vehicle", "fb_status", "fb_suggested_destinations", "fb_suggested_home_listings", "fb_suggested_hotels", "fb_suggested_jobs", "fb_suggested_local_service_businesses", "fb_suggested_location_based_items", "fb_suggested_vehicles", "fb_transmission", "fb_travel_class", "fb_travel_end", "fb_travel_start", "fb_trim", "fb_user_bucket", "fb_value", "fb_vin", "fb_year", "lead_event_source", "predicted_ltv", "product_catalog_id", "app_user_id", v8.i.W, Constants.EVENT_NAME_EVENT_KEY, Constants.EVENT_NAME_MD5_EVENT_KEY, "_implicitlyLogged", "_inBackground", "_isTimedEvent", Constants.LOG_TIME_APP_EVENT_KEY, "_session_id", "_ui", "_valueToUpdate", com.facebook.appevents.codeless.internal.Constants.IS_CODELESS_EVENT_KEY, "_is_suggested_event", "_fb_pixel_referral_id", "fb_pixel_id", "trace_id", "subscription_id", "event_id", "_restrictedParams", "_onDeviceParams", "purchase_valid_result_type", "core_lib_included", "login_lib_included", "share_lib_included", "place_lib_included", "messenger_lib_included", "applinks_lib_included", "marketing_lib_included", "_codeless_action", "sdk_initialized", "billing_client_lib_included", "billing_service_lib_included", "user_data_keys", "device_push_token", AppEventsConstants.EVENT_PARAM_PACKAGE_FP, AppEventsConstants.EVENT_PARAM_APP_CERT_HASH, "aggregate_id", "anonymous_id", "campaign_ids", "fb_post_attachment", AppLovinEventParameters.IN_APP_PURCHASE_DATA, "ad_type", AppEventsConstants.EVENT_PARAM_CONTENT, AppEventsConstants.EVENT_PARAM_CONTENT_ID, AppEventsConstants.EVENT_PARAM_DESCRIPTION, AppEventsConstants.EVENT_PARAM_LEVEL, AppEventsConstants.EVENT_PARAM_MAX_RATING_VALUE, AppEventsConstants.EVENT_PARAM_PAYMENT_INFO_AVAILABLE, AppEventsConstants.EVENT_PARAM_REGISTRATION_METHOD, AppEventsConstants.EVENT_PARAM_SUCCESS, "pm", "_audiencePropertyIds", "cs_maca"); return hashSetOf; } }); defaultStandardParameterNames$delegate = lazy; } public final HashSet getDefaultStandardParameterNames() { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { return (HashSet) defaultStandardParameterNames$delegate.getValue(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return null; } } public static final void enable() { if (CrashShieldHandler.isObjectCrashing(ProtectedModeManager.class)) { return; } try { enabled = true; INSTANCE.loadStandardParams(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, ProtectedModeManager.class); } } public static final void disable() { if (CrashShieldHandler.isObjectCrashing(ProtectedModeManager.class)) { return; } try { enabled = false; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, ProtectedModeManager.class); } } private final void loadStandardParams() { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { FetchedAppSettingsManager fetchedAppSettingsManager = FetchedAppSettingsManager.INSTANCE; FetchedAppSettings queryAppSettings = FetchedAppSettingsManager.queryAppSettings(FacebookSdk.getApplicationId(), false); if (queryAppSettings == null) { return; } HashSet convertJSONArrayToHashSet = convertJSONArrayToHashSet(queryAppSettings.getProtectedModeStandardParamsSetting()); if (convertJSONArrayToHashSet == null) { convertJSONArrayToHashSet = getDefaultStandardParameterNames(); } standardParams = convertJSONArrayToHashSet; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } private final HashSet convertJSONArrayToHashSet(JSONArray jSONArray) { if (!CrashShieldHandler.isObjectCrashing(this) && jSONArray != null) { try { if (jSONArray.length() != 0) { HashSet hashSet = new HashSet<>(); int length = jSONArray.length(); if (length > 0) { int i = 0; while (true) { int i2 = i + 1; String string = jSONArray.getString(i); Intrinsics.checkNotNullExpressionValue(string, "jsonArray.getString(i)"); hashSet.add(string); if (i2 >= length) { break; } i = i2; } } return hashSet; } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } return null; } public static final void processParametersForProtectedMode(Bundle bundle) { if (CrashShieldHandler.isObjectCrashing(ProtectedModeManager.class)) { return; } try { if (enabled && bundle != null && !bundle.isEmpty() && standardParams != null) { ArrayList arrayList = new ArrayList(); Set keySet = bundle.keySet(); Intrinsics.checkNotNullExpressionValue(keySet, "parameters.keySet()"); for (String param : keySet) { HashSet hashSet = standardParams; Intrinsics.checkNotNull(hashSet); if (!hashSet.contains(param)) { Intrinsics.checkNotNullExpressionValue(param, "param"); arrayList.add(param); } } Iterator it = arrayList.iterator(); while (it.hasNext()) { bundle.remove((String) it.next()); } bundle.putString(PROTECTED_MODE_IS_APPLIED_KEY, "1"); } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, ProtectedModeManager.class); } } public final boolean protectedModeIsApplied(Bundle parameters) { if (CrashShieldHandler.isObjectCrashing(this)) { return false; } try { Intrinsics.checkNotNullParameter(parameters, "parameters"); if (parameters.containsKey(PROTECTED_MODE_IS_APPLIED_KEY)) { return Intrinsics.areEqual(parameters.get(PROTECTED_MODE_IS_APPLIED_KEY), "1"); } return false; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return false; } } }