package com.appsflyer;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import com.appsflyer.internal.ai;
import com.bytedance.covode.number.Covode;

public class MultipleInstallBroadcastReceiver extends BroadcastReceiver {
    static {
        Covode.recordClassIndex(2556);
    }

    public static String INVOKEVIRTUAL_com_appsflyer_MultipleInstallBroadcastReceiver_com_ss_android_ugc_aweme_lancet_IntentLancet_getStringExtra(Intent intent, String str) {
        try {
            return intent.getStringExtra(str);
        } catch (Exception unused) {
            return null;
        }
    }

    public void onReceive(Context context, Intent intent) {
        if (intent != null) {
            try {
                String INVOKEVIRTUAL_com_appsflyer_MultipleInstallBroadcastReceiver_com_ss_android_ugc_aweme_lancet_IntentLancet_getStringExtra = INVOKEVIRTUAL_com_appsflyer_MultipleInstallBroadcastReceiver_com_ss_android_ugc_aweme_lancet_IntentLancet_getStringExtra(intent, "referrer");
                if (!(INVOKEVIRTUAL_com_appsflyer_MultipleInstallBroadcastReceiver_com_ss_android_ugc_aweme_lancet_IntentLancet_getStringExtra == null || ai.values(context).getString("referrer", (String) null) == null)) {
                    ai.valueOf().AFKeystoreWrapper(context, INVOKEVIRTUAL_com_appsflyer_MultipleInstallBroadcastReceiver_com_ss_android_ugc_aweme_lancet_IntentLancet_getStringExtra);
                    return;
                }
            } catch (Throwable th) {
                AFLogger.valueOf("error in BroadcastReceiver ", th);
            }
            AFLogger.valueOf("MultipleInstallBroadcastReceiver called");
            ai.valueOf().values(context, intent);
            for (ResolveInfo next : context.getPackageManager().queryBroadcastReceivers(new Intent("com.android.vending.INSTALL_REFERRER"), 0)) {
                String action = intent.getAction();
                if (next.activityInfo.packageName.equals(context.getPackageName()) && "com.android.vending.INSTALL_REFERRER".equals(action) && !getClass().getName().equals(next.activityInfo.name)) {
                    StringBuilder sb = new StringBuilder("trigger onReceive: class: ");
                    sb.append(next.activityInfo.name);
                    AFLogger.valueOf(sb.toString());
                    try {
                        ((BroadcastReceiver) Class.forName(next.activityInfo.name).newInstance()).onReceive(context, intent);
                    } catch (Throwable th2) {
                        StringBuilder sb2 = new StringBuilder("error in BroadcastReceiver ");
                        sb2.append(next.activityInfo.name);
                        AFLogger.valueOf(sb2.toString(), th2);
                    }
                }
            }
        }
    }
}
