package com.google.android.play.core.integrity;

import C3.A;
import C3.C0129e;
import C3.E;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IInterface;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes3.dex */
final class bn {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    final C0129e f13664a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final A f13665b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final String f13666c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private final TaskCompletionSource f13667d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private final at f13668e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final k f13669f;

    public bn(Context context, A a6, at atVar, k kVar) {
        TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
        this.f13667d = taskCompletionSource;
        this.f13666c = context.getPackageName();
        this.f13665b = a6;
        this.f13668e = atVar;
        this.f13669f = kVar;
        C0129e c0129e = new C0129e(context, a6, "ExpressIntegrityService", bo.f13670a, new E() { // from class: com.google.android.play.core.integrity.bd
            @Override // C3.E
            public final Object a(IBinder iBinder) {
                int i6 = C3.p.f737i;
                if (iBinder == null) {
                    return null;
                }
                IInterface iInterfaceQueryLocalInterface = iBinder.queryLocalInterface("com.google.android.play.core.integrity.protocol.IExpressIntegrityService");
                return iInterfaceQueryLocalInterface instanceof C3.q ? (C3.q) iInterfaceQueryLocalInterface : new C3.o(iBinder, "com.google.android.play.core.integrity.protocol.IExpressIntegrityService");
            }
        });
        this.f13664a = c0129e;
        c0129e.a().post(new be(this, taskCompletionSource, context));
    }

    public static Bundle a(bn bnVar, String str, long j4, long j6, int i6) {
        Bundle bundle = new Bundle();
        bundle.putString("package.name", bnVar.f13666c);
        bundle.putLong("cloud.prj", j4);
        bundle.putString("nonce", str);
        bundle.putLong("warm.up.sid", j6);
        bundle.putInt("playcore.integrity.version.major", 1);
        bundle.putInt("playcore.integrity.version.minor", 3);
        bundle.putInt("playcore.integrity.version.patch", 0);
        bundle.putInt("webview.request.mode", 0);
        ArrayList arrayList = new ArrayList();
        arrayList.add(new C3.n(5, System.currentTimeMillis()));
        bundle.putParcelableArrayList("event_timestamps", new ArrayList<>(A4.g.d(arrayList)));
        return bundle;
    }

    public static Bundle b(bn bnVar, long j4, int i6) {
        Bundle bundle = new Bundle();
        bundle.putString("package.name", bnVar.f13666c);
        bundle.putLong("cloud.prj", j4);
        bundle.putInt("playcore.integrity.version.major", 1);
        bundle.putInt("playcore.integrity.version.minor", 3);
        bundle.putInt("playcore.integrity.version.patch", 0);
        bundle.putInt("webview.request.mode", 0);
        ArrayList arrayList = new ArrayList();
        arrayList.add(new C3.n(4, System.currentTimeMillis()));
        bundle.putParcelableArrayList("event_timestamps", new ArrayList<>(A4.g.d(arrayList)));
        return bundle;
    }

    public static /* bridge */ /* synthetic */ boolean k(bn bnVar) {
        return bnVar.f13667d.getTask().isSuccessful() && ((Integer) bnVar.f13667d.getTask().getResult()).intValue() == 0;
    }

    public final Task c(Activity activity, Bundle bundle) {
        int i6 = bundle.getInt("dialog.intent.type");
        this.f13665b.b("requestAndShowDialog(%s)", Integer.valueOf(i6));
        TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
        this.f13664a.c(new bh(this, taskCompletionSource, bundle, activity, taskCompletionSource, i6), taskCompletionSource);
        return taskCompletionSource.getTask();
    }

    public final Task d(String str, long j4, long j6, int i6) {
        this.f13665b.b("requestExpressIntegrityToken(%s)", Long.valueOf(j6));
        TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
        this.f13664a.c(new bg(this, taskCompletionSource, 0, str, j4, j6, taskCompletionSource), taskCompletionSource);
        return taskCompletionSource.getTask();
    }

    public final Task e(long j4, int i6) {
        this.f13665b.b("warmUpIntegrityToken(%s)", Long.valueOf(j4));
        TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
        this.f13664a.c(new bf(this, taskCompletionSource, 0, j4, taskCompletionSource), taskCompletionSource);
        return taskCompletionSource.getTask();
    }
}
