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

import android.app.Notification;
import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class b1 implements ServiceConnection {

    /* renamed from: a, reason: collision with root package name */
    private final rj.h0 f13816a = new rj.h0("ExtractionForegroundServiceConnection");

    /* renamed from: b, reason: collision with root package name */
    private final List f13817b = new ArrayList();

    /* renamed from: c, reason: collision with root package name */
    private final Context f13818c;

    /* renamed from: d, reason: collision with root package name */
    private ExtractionForegroundService f13819d;

    /* renamed from: e, reason: collision with root package name */
    private Notification f13820e;

    /* JADX INFO: Access modifiers changed from: package-private */
    public b1(Context context) {
        this.f13818c = context;
    }

    private final void d() {
        ArrayList arrayList;
        synchronized (this.f13817b) {
            arrayList = new ArrayList(this.f13817b);
            this.f13817b.clear();
        }
        int size = arrayList.size();
        for (int i10 = 0; i10 < size; i10++) {
            try {
                ((rj.d0) arrayList.get(i10)).K(new Bundle(), new Bundle());
            } catch (RemoteException unused) {
                this.f13816a.b("Could not resolve Play Store service state update callback.", new Object[0]);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final void a(Notification notification) {
        this.f13820e = notification;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final void b() {
        this.f13816a.a("Stopping foreground installation service.", new Object[0]);
        this.f13818c.unbindService(this);
        ExtractionForegroundService extractionForegroundService = this.f13819d;
        if (extractionForegroundService != null) {
            extractionForegroundService.a();
        }
        d();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final void c(rj.d0 d0Var) {
        synchronized (this.f13817b) {
            this.f13817b.add(d0Var);
        }
    }

    @Override // android.content.ServiceConnection
    public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        this.f13816a.a("Starting foreground installation service.", new Object[0]);
        ExtractionForegroundService extractionForegroundService = ((a1) iBinder).f13811e;
        this.f13819d = extractionForegroundService;
        extractionForegroundService.startForeground(-1883842196, this.f13820e);
        d();
    }

    @Override // android.content.ServiceConnection
    public final void onServiceDisconnected(ComponentName componentName) {
    }
}
