package com.appsflyer.internal;

import android.content.Context;
import android.content.pm.PackageItemInfo;
import android.content.pm.ProviderInfo;
import android.content.pm.Signature;
import android.database.Cursor;
import android.net.Uri;
import android.util.Base64;
import com.facebook.internal.AttributionIdentifiers;
import java.io.ByteArrayInputStream;
import java.security.MessageDigest;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public final class aa {

    /* renamed from: ॱ  reason: contains not printable characters */
    public final Context f1959;

    public aa(Context context) {
        this.f1959 = context;
    }

    /* renamed from: ˊ  reason: contains not printable characters */
    public final String m1162() {
        String str;
        ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
        try {
            str = (String) newSingleThreadExecutor.submit(new Callable<String>() {
                /* class com.appsflyer.internal.aa.AnonymousClass1 */

                /* Return type fixed from 'java.lang.Object' to match base method */
                @Override // java.util.concurrent.Callable
                public final /* synthetic */ String call() throws Exception {
                    ProviderInfo resolveContentProvider = aa.this.f1959.getPackageManager().resolveContentProvider(AttributionIdentifiers.ATTRIBUTION_ID_CONTENT_PROVIDER, 128);
                    String str = null;
                    if (resolveContentProvider != null) {
                        Signature[] signatureArr = aa.this.f1959.getPackageManager().getPackageInfo(((PackageItemInfo) resolveContentProvider).packageName, 64).signatures;
                        MessageDigest instance = MessageDigest.getInstance("SHA1");
                        instance.update(((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(signatureArr[0].toByteArray()))).getEncoded());
                        if (Base64.encodeToString(instance.digest(), 2).equals("ijxLJi1yGs1JpL+X1SExmchvork=")) {
                            Cursor query = aa.this.f1959.getContentResolver().query(Uri.parse("content://com.facebook.katana.provider.AttributionIdProvider"), new String[]{AttributionIdentifiers.ATTRIBUTION_ID_COLUMN_NAME}, null, null, null);
                            if (query != null && query.moveToFirst()) {
                                str = query.getString(query.getColumnIndex(AttributionIdentifiers.ATTRIBUTION_ID_COLUMN_NAME));
                            }
                            if (query != null) {
                                query.close();
                            }
                        }
                    }
                    return str;
                }
            }).get(500, TimeUnit.MILLISECONDS);
        } catch (InterruptedException | ExecutionException | TimeoutException unused) {
            str = null;
        }
        newSingleThreadExecutor.shutdown();
        return str;
    }
}
