package p138.p176.p177.p242.p265.p266;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import java.util.List;
import p138.p176.p177.p242.p246.p252.C4306;
import p138.p176.p177.p242.p246.p255.C4321;
import p138.p176.p177.p242.p246.p255.C4322;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ބ.֏.ٱ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C4880 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C4974 f14686;

    public C4880(C4974 c4974) {
        this.f14686 = c4974;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8206(String str) {
        if (str == null || str.isEmpty()) {
            this.f14686.mo8165().f14448.m8034("Install Referrer Reporter was called with invalid app package name");
            return;
        }
        this.f14686.mo8163().mo8008();
        if (!m8207()) {
            this.f14686.mo8165().f14450.m8034("Install Referrer Reporter is not available");
            return;
        }
        ServiceConnectionC4872 serviceConnectionC4872 = new ServiceConnectionC4872(this, str);
        this.f14686.mo8163().mo8008();
        Intent intent = new Intent("com.google.android.finsky.BIND_GET_INSTALL_REFERRER_SERVICE");
        intent.setComponent(new ComponentName("com.android.vending", "com.google.android.finsky.externalreferrer.GetInstallReferrerService"));
        PackageManager packageManager = this.f14686.f15009.getPackageManager();
        if (packageManager == null) {
            this.f14686.mo8165().f14448.m8034("Failed to obtain Package Manager to verify binding conditions for Install Referrer");
            return;
        }
        List<ResolveInfo> listQueryIntentServices = packageManager.queryIntentServices(intent, 0);
        if (listQueryIntentServices == null || listQueryIntentServices.isEmpty()) {
            this.f14686.mo8165().f14450.m8034("Play Service for fetching Install Referrer is unavailable on device");
            return;
        }
        ServiceInfo serviceInfo = listQueryIntentServices.get(0).serviceInfo;
        if (serviceInfo != null) {
            String str2 = serviceInfo.packageName;
            if (serviceInfo.name == null || !"com.android.vending".equals(str2) || !m8207()) {
                this.f14686.mo8165().f14447.m8034("Play Store version 8.3.73 or higher required for Install Referrer");
                return;
            }
            Intent intent2 = new Intent(intent);
            try {
                C4306 c4306M7206 = C4306.m7206();
                Context context = this.f14686.f15009;
                if (c4306M7206 == null) {
                    throw null;
                }
                context.getClass().getName();
                this.f14686.mo8165().f14452.m8035("Install Referrer Service is", c4306M7206.m7208(context, intent2, serviceConnectionC4872, 1) ? "available" : "not available");
            } catch (Exception e) {
                this.f14686.mo8165().f14444.m8035("Exception occurred while binding to Install Referrer Service", e.getMessage());
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m8207() {
        try {
            C4321 c4321M7223 = C4322.m7223(this.f14686.f15009);
            if (c4321M7223 != null) {
                return c4321M7223.f13621.getPackageManager().getPackageInfo("com.android.vending", 128).versionCode >= 80837300;
            }
            this.f14686.mo8165().f14452.m8034("Failed to get PackageManager for Install Referrer Play Store compatibility check");
            return false;
        } catch (Exception e) {
            this.f14686.mo8165().f14452.m8035("Failed to retrieve Play Store version for Install Referrer", e);
            return false;
        }
    }
}
