package com.appsflyer.internal;

import X.2XJ;
import X.3GY;
import X.8n2;
import android.content.ContentResolver;
import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Pair;
import com.android.billingclient.api.Purchase;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerProperties;
import com.appsflyer.compat.function.Consumer;
import com.appsflyer.compat.function.Function;
import com.appsflyer.internal.c;
import com.bytedance.covode.number.Covode;
import com.google.android.gms.common.GoogleApiAvailability;
import java.util.List;
import java.util.Map;

public final class ad {
    public static String AFInAppEventParameterName;
    public static Boolean AFKeystoreWrapper;
    public final Consumer<String> AFInAppEventType;
    public final boolean init;
    public final Consumer<String> valueOf;
    public final Function<List<Purchase>, Map<String, String>> values;

    static {
        Covode.recordClassIndex(2582);
    }

    public static String com_appsflyer_internal_ad_android_provider_Settings$Secure_getString(ContentResolver contentResolver, String str) {
        3GY.LIZ(102004);
        Pair LIZ = 3GY.LIZ((Object) null, Settings.Secure.class, new Object[]{contentResolver, str}, 102004, "java.lang.String", false, 189941864, 2);
        return ((Boolean) LIZ.first).booleanValue() ? (String) LIZ.second : Settings.Secure.getString(contentResolver, str);
    }

    public ad() {
    }

    public static boolean values() {
        Boolean bool = AFKeystoreWrapper;
        if (bool == null || bool.booleanValue()) {
            return true;
        }
        return false;
    }

    public final int hashCode() {
        int i;
        int i2;
        Function<List<Purchase>, Map<String, String>> function = this.values;
        int i3 = 0;
        if (function != null) {
            i = function.hashCode();
        } else {
            i = 0;
        }
        int i4 = i * 31;
        Consumer<String> consumer = this.AFInAppEventType;
        if (consumer != null) {
            i2 = consumer.hashCode();
        } else {
            i2 = 0;
        }
        int i5 = (i4 + i2) * 31;
        Consumer<String> consumer2 = this.valueOf;
        if (consumer2 != null) {
            i3 = consumer2.hashCode();
        }
        return ((i5 + i3) * 31) + (this.init ? 1 : 0);
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder("ArsFeatureParams{additionalParameters=");
        sb.append(this.values);
        sb.append(", success=");
        sb.append(this.AFInAppEventType);
        sb.append(", failure=");
        sb.append(this.valueOf);
        sb.append(", sandbox=");
        sb.append(this.init);
        sb.append('}');
        return sb.toString();
    }

    public static c.d.b AFInAppEventParameterName(ContentResolver contentResolver) {
        String str;
        if (!values() || contentResolver == null || AppsFlyerProperties.getInstance().getString("amazon_aid") != null || !"Amazon".equals(Build.MANUFACTURER)) {
            return null;
        }
        int i = Settings.Secure.getInt(contentResolver, "limit_ad_tracking", 2);
        if (i == 0) {
            return new c.d.b(INVOKESTATIC_com_appsflyer_internal_ad_com_ss_android_ugc_aweme_lancet_process_AnndroidIdSecureLancet_getString(contentResolver, "advertising_id"), Boolean.FALSE);
        }
        if (i == 2) {
            return null;
        }
        try {
            str = INVOKESTATIC_com_appsflyer_internal_ad_com_ss_android_ugc_aweme_lancet_process_AnndroidIdSecureLancet_getString(contentResolver, "advertising_id");
        } catch (Throwable th) {
            AFLogger.valueOf("Couldn't fetch Amazon Advertising ID (Ad-Tracking is limited!)", th);
            str = "";
        }
        return new c.d.b(str, Boolean.TRUE);
    }

    /* JADX WARNING: Removed duplicated region for block: B:7:0x0010  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static com.appsflyer.internal.c.d.b values(android.content.Context r6) {
        /*
            com.appsflyer.AppsFlyerProperties r5 = com.appsflyer.AppsFlyerProperties.getInstance()
            java.lang.String r1 = AFInAppEventParameterName
            r4 = 1
            if (r1 == 0) goto L_0x0054
            r3 = 1
        L_0x000a:
            r2 = 0
            if (r3 == 0) goto L_0x001c
        L_0x000d:
            r0 = r2
        L_0x000e:
            if (r1 == 0) goto L_0x0056
            com.appsflyer.internal.c$d$b r2 = new com.appsflyer.internal.c$d$b
            r2.<init>(r1, r0)
            java.lang.Boolean r0 = java.lang.Boolean.valueOf(r3)
            r2.valueOf = r0
            return r2
        L_0x001c:
            java.lang.Boolean r0 = AFKeystoreWrapper
            if (r0 == 0) goto L_0x0026
            boolean r0 = r0.booleanValue()
            if (r0 != 0) goto L_0x0032
        L_0x0026:
            java.lang.Boolean r0 = AFKeystoreWrapper
            if (r0 != 0) goto L_0x0056
            java.lang.String r0 = "collectOAID"
            boolean r0 = r5.getBoolean(r0, r4)
            if (r0 == 0) goto L_0x0056
        L_0x0032:
            com.appsflyer.oaid.OaidClient r1 = new com.appsflyer.oaid.OaidClient     // Catch:{ all -> 0x004d }
            r1.<init>(r6)     // Catch:{ all -> 0x004d }
            boolean r0 = r5.isEnableLog()     // Catch:{ all -> 0x004d }
            r1.setLogging(r0)     // Catch:{ all -> 0x004d }
            com.appsflyer.oaid.OaidClient$Info r0 = r1.fetch()     // Catch:{ all -> 0x004d }
            if (r0 == 0) goto L_0x0056
            java.lang.String r1 = r0.getId()     // Catch:{ all -> 0x004d }
            java.lang.Boolean r0 = r0.getLat()     // Catch:{ all -> 0x004e }
            goto L_0x000e
        L_0x004d:
            r1 = r2
        L_0x004e:
            java.lang.String r0 = "No OAID library"
            com.appsflyer.AFLogger.AFInAppEventType(r0)
            goto L_0x000d
        L_0x0054:
            r3 = 0
            goto L_0x000a
        L_0x0056:
            return r2
        */
        throw new UnsupportedOperationException("Method not decompiled: com.appsflyer.internal.ad.values(android.content.Context):com.appsflyer.internal.c$d$b");
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            ad adVar = (ad) obj;
            if (this.init != adVar.init) {
                return false;
            }
            Function<List<Purchase>, Map<String, String>> function = this.values;
            if (function == null ? adVar.values != null : !function.equals(adVar.values)) {
                return false;
            }
            Consumer<String> consumer = this.AFInAppEventType;
            if (consumer == null ? adVar.AFInAppEventType != null : !consumer.equals(adVar.AFInAppEventType)) {
                return false;
            }
            Consumer<String> consumer2 = this.valueOf;
            Consumer<String> consumer3 = adVar.valueOf;
            if (consumer2 != null) {
                return consumer2.equals(consumer3);
            }
            if (consumer3 == null) {
                return true;
            }
        }
        return false;
    }

    public static String INVOKESTATIC_com_appsflyer_internal_ad_com_ss_android_ugc_aweme_lancet_process_AnndroidIdSecureLancet_getString(ContentResolver contentResolver, String str) {
        if (!TextUtils.equals(str, "android_id")) {
            return com_appsflyer_internal_ad_android_provider_Settings$Secure_getString(contentResolver, str);
        }
        if (TextUtils.isEmpty(2XJ.LIZ)) {
            2XJ.LIZ = com_appsflyer_internal_ad_android_provider_Settings$Secure_getString(contentResolver, str);
        }
        return 2XJ.LIZ;
    }

    public static int INVOKEVIRTUAL_com_appsflyer_internal_ad_com_ss_android_ugc_aweme_lancet_process_AwemeMetaDataLancet_isGooglePlayServicesAvailable(GoogleApiAvailability googleApiAvailability, Context context) {
        if (8n2.LJIIIZ && 8n2.LJI >= 0) {
            return 8n2.LJI;
        }
        int isGooglePlayServicesAvailable = googleApiAvailability.isGooglePlayServicesAvailable(context);
        8n2.LJI = isGooglePlayServicesAvailable;
        return isGooglePlayServicesAvailable;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:17:0x003e, code lost:
        if (r3.length() == 0) goto L_0x0040;
     */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x0085 A[SYNTHETIC, Splitter:B:31:0x0085] */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x00f7  */
    /* JADX WARNING: Removed duplicated region for block: B:48:0x011b  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static com.appsflyer.internal.c.d.b AFInAppEventType(android.content.Context r11, java.util.Map<java.lang.String, java.lang.Object> r12) {
        /*
            java.lang.String r4 = "advertiserIdEnabled"
            java.lang.String r6 = "advertiserId"
            boolean r0 = values()
            r2 = 0
            if (r0 != 0) goto L_0x000c
            return r2
        L_0x000c:
            java.lang.String r0 = "Trying to fetch GAID.."
            com.appsflyer.AFLogger.valueOf((java.lang.String) r0)
            r0 = 0
            java.lang.StringBuilder r7 = new java.lang.StringBuilder
            r7.<init>()
            r8 = -1
            com.google.android.gms.common.GoogleApiAvailability r0 = com.google.android.gms.common.GoogleApiAvailability.getInstance()     // Catch:{ all -> 0x0020 }
            int r8 = INVOKEVIRTUAL_com_appsflyer_internal_ad_com_ss_android_ugc_aweme_lancet_process_AwemeMetaDataLancet_isGooglePlayServicesAvailable(r0, r11)     // Catch:{ all -> 0x0020 }
        L_0x0020:
            r5 = 1
            java.lang.String r0 = "com.google.android.gms.ads.identifier.AdvertisingIdClient"
            java.lang.Class.forName(r0)     // Catch:{ all -> 0x0054 }
            com.google.android.gms.ads.identifier.AdvertisingIdClient$Info r0 = com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo(r11)     // Catch:{ all -> 0x0054 }
            if (r0 == 0) goto L_0x0047
            java.lang.String r3 = r0.getId()     // Catch:{ all -> 0x0054 }
            boolean r0 = r0.isLimitAdTrackingEnabled()     // Catch:{ all -> 0x0058 }
            java.lang.Boolean r2 = java.lang.Boolean.valueOf(r0)     // Catch:{ all -> 0x0058 }
            if (r3 == 0) goto L_0x0040
            int r0 = r3.length()     // Catch:{ all -> 0x005b }
            if (r0 != 0) goto L_0x00e6
        L_0x0040:
            java.lang.String r0 = "emptyOrNull |"
            r7.append(r0)     // Catch:{ all -> 0x005b }
            goto L_0x00e6
        L_0x0047:
            java.lang.String r0 = "gpsAdInfo-null |"
            r7.append(r0)     // Catch:{ all -> 0x0054 }
            java.lang.IllegalStateException r1 = new java.lang.IllegalStateException     // Catch:{ all -> 0x0054 }
            java.lang.String r0 = "GpsAdIndo is null"
            r1.<init>(r0)     // Catch:{ all -> 0x0054 }
            throw r1     // Catch:{ all -> 0x0054 }
        L_0x0054:
            r1 = move-exception
            r3 = r2
            r2 = r3
            goto L_0x0059
        L_0x0058:
            r1 = move-exception
        L_0x0059:
            r10 = 0
            goto L_0x005d
        L_0x005b:
            r1 = move-exception
            r10 = 1
        L_0x005d:
            java.lang.String r0 = r1.getMessage()
            com.appsflyer.AFLogger.valueOf(r0, r1)
            java.lang.Class r0 = r1.getClass()
            java.lang.String r0 = r0.getSimpleName()
            r7.append(r0)
            java.lang.String r9 = " |"
            r7.append(r9)
            java.lang.String r0 = "WARNING: Google Play Services is missing."
            com.appsflyer.AFLogger.valueOf((java.lang.String) r0)
            com.appsflyer.AppsFlyerProperties r1 = com.appsflyer.AppsFlyerProperties.getInstance()
            java.lang.String r0 = "enableGpsFallback"
            boolean r0 = r1.getBoolean(r0, r5)
            if (r0 == 0) goto L_0x00e7
            com.appsflyer.internal.aa$d r0 = com.appsflyer.internal.aa.values(r11)     // Catch:{ all -> 0x00a1 }
            java.lang.String r3 = r0.valueOf     // Catch:{ all -> 0x00a1 }
            boolean r0 = r0.valueOf()     // Catch:{ all -> 0x00a1 }
            java.lang.Boolean r2 = java.lang.Boolean.valueOf(r0)     // Catch:{ all -> 0x00a1 }
            if (r3 == 0) goto L_0x009b
            int r0 = r3.length()     // Catch:{ all -> 0x00a1 }
            if (r0 != 0) goto L_0x00e7
        L_0x009b:
            java.lang.String r0 = "emptyOrNull (bypass) |"
            r7.append(r0)     // Catch:{ all -> 0x00a1 }
            goto L_0x00e7
        L_0x00a1:
            r1 = move-exception
            java.lang.String r0 = r1.getMessage()
            com.appsflyer.AFLogger.valueOf(r0, r1)
            java.lang.Class r0 = r1.getClass()
            java.lang.String r0 = r0.getSimpleName()
            r7.append(r0)
            r7.append(r9)
            com.appsflyer.AppsFlyerProperties r0 = com.appsflyer.AppsFlyerProperties.getInstance()
            java.lang.String r3 = r0.getString(r6)
            com.appsflyer.AppsFlyerProperties r0 = com.appsflyer.AppsFlyerProperties.getInstance()
            java.lang.String r0 = r0.getString(r4)
            boolean r0 = java.lang.Boolean.parseBoolean(r0)
            r0 = r0 ^ r5
            java.lang.Boolean r2 = java.lang.Boolean.valueOf(r0)
            java.lang.String r0 = r1.getLocalizedMessage()
            if (r0 == 0) goto L_0x00de
            java.lang.String r0 = r1.getLocalizedMessage()
            com.appsflyer.AFLogger.valueOf((java.lang.String) r0)
            goto L_0x00e7
        L_0x00de:
            java.lang.String r0 = r1.toString()
            com.appsflyer.AFLogger.valueOf((java.lang.String) r0)
            goto L_0x00e7
        L_0x00e6:
            r10 = 1
        L_0x00e7:
            java.lang.Class r0 = r11.getClass()
            java.lang.String r1 = r0.getName()
            java.lang.String r0 = "android.app.ReceiverRestrictedContext"
            boolean r0 = r1.equals(r0)
            if (r0 == 0) goto L_0x0115
            com.appsflyer.AppsFlyerProperties r0 = com.appsflyer.AppsFlyerProperties.getInstance()
            java.lang.String r3 = r0.getString(r6)
            com.appsflyer.AppsFlyerProperties r0 = com.appsflyer.AppsFlyerProperties.getInstance()
            java.lang.String r0 = r0.getString(r4)
            boolean r0 = java.lang.Boolean.parseBoolean(r0)
            r0 = r0 ^ r5
            java.lang.Boolean r2 = java.lang.Boolean.valueOf(r0)
            java.lang.String r0 = "context = android.app.ReceiverRestrictedContext |"
            r7.append(r0)
        L_0x0115:
            int r0 = r7.length()
            if (r0 <= 0) goto L_0x0134
            java.lang.StringBuilder r1 = new java.lang.StringBuilder
            r1.<init>()
            r1.append(r8)
            java.lang.String r0 = ": "
            r1.append(r0)
            r1.append(r7)
            java.lang.String r1 = r1.toString()
            java.lang.String r0 = "gaidError"
            r12.put(r0, r1)
        L_0x0134:
            if (r3 == 0) goto L_0x0167
            if (r2 == 0) goto L_0x0167
            r12.put(r6, r3)
            boolean r0 = r2.booleanValue()
            r0 = r0 ^ r5
            java.lang.String r0 = java.lang.String.valueOf(r0)
            r12.put(r4, r0)
            com.appsflyer.AppsFlyerProperties r0 = com.appsflyer.AppsFlyerProperties.getInstance()
            r0.set((java.lang.String) r6, (java.lang.String) r3)
            com.appsflyer.AppsFlyerProperties r1 = com.appsflyer.AppsFlyerProperties.getInstance()
            boolean r0 = r2.booleanValue()
            r0 = r0 ^ r5
            java.lang.String r0 = java.lang.String.valueOf(r0)
            r1.set((java.lang.String) r4, (java.lang.String) r0)
            java.lang.String r1 = java.lang.String.valueOf(r10)
            java.lang.String r0 = "isGaidWithGps"
            r12.put(r0, r1)
        L_0x0167:
            com.appsflyer.internal.c$d$b r0 = new com.appsflyer.internal.c$d$b
            r0.<init>(r3, r2)
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.appsflyer.internal.ad.AFInAppEventType(android.content.Context, java.util.Map):com.appsflyer.internal.c$d$b");
    }

    public ad(Function<List<Purchase>, Map<String, String>> function, Consumer<String> consumer, Consumer<String> consumer2, boolean z) {
        this.values = function;
        this.AFInAppEventType = consumer;
        this.valueOf = consumer2;
        this.init = z;
    }
}
