package com.google.firebase.messaging;

import android.content.SharedPreferences;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import java.util.ArrayDeque;
import java.util.concurrent.Executor;

/* JADX INFO: loaded from: classes2.dex */
public final class b0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final SharedPreferences f24153a;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Executor f24157e;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final ArrayDeque f24156d = new ArrayDeque();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final String f24154b = "topic_operation_queue";

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final String f24155c = ",";

    public b0(SharedPreferences sharedPreferences, Executor executor) {
        this.f24153a = sharedPreferences;
        this.f24157e = executor;
    }

    public static b0 a(SharedPreferences sharedPreferences, Executor executor) {
        b0 b0Var = new b0(sharedPreferences, executor);
        synchronized (b0Var.f24156d) {
            try {
                b0Var.f24156d.clear();
                String string = b0Var.f24153a.getString(b0Var.f24154b, "");
                if (!TextUtils.isEmpty(string) && string.contains(b0Var.f24155c)) {
                    String[] strArrSplit = string.split(b0Var.f24155c, -1);
                    int length = strArrSplit.length;
                    for (String str : strArrSplit) {
                        if (!TextUtils.isEmpty(str)) {
                            b0Var.f24156d.add(str);
                        }
                    }
                }
            } finally {
            }
        }
        return b0Var;
    }

    public final String b() {
        String str;
        synchronized (this.f24156d) {
            str = (String) this.f24156d.remove();
            if (str != null) {
                this.f24157e.execute(new y.a(this, 19));
            }
        }
        return str;
    }

    @Nullable
    public String peek() {
        String str;
        synchronized (this.f24156d) {
            str = (String) this.f24156d.peek();
        }
        return str;
    }

    public boolean remove(@Nullable Object obj) {
        boolean zRemove;
        synchronized (this.f24156d) {
            zRemove = this.f24156d.remove(obj);
            if (zRemove) {
                this.f24157e.execute(new y.a(this, 19));
            }
        }
        return zRemove;
    }
}
