package Q4;

import Z6.InterfaceC0382w;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;
import com.google.android.gms.internal.measurement.C1;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public final class a0 extends G6.i implements O6.p {

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public int f5731u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final /* synthetic */ C2.a f5732v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final /* synthetic */ ArrayList f5733w;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public a0(C2.a aVar, ArrayList arrayList, E6.d dVar) {
        super(2, dVar);
        this.f5732v = aVar;
        this.f5733w = arrayList;
    }

    @Override // O6.p
    public final Object k(Object obj, Object obj2) {
        return ((a0) m((E6.d) obj2, (InterfaceC0382w) obj)).p(A6.n.f457a);
    }

    @Override // G6.a
    public final E6.d m(E6.d dVar, Object obj) {
        return new a0(this.f5732v, this.f5733w, dVar);
    }

    @Override // G6.a
    public final Object p(Object obj) throws Throwable {
        F6.a aVar = F6.a.f2580q;
        int i = this.f5731u;
        if (i == 0) {
            C1.N(obj);
            R4.c cVar = R4.c.f6074a;
            this.f5731u = 1;
            obj = cVar.b(this);
            if (obj == aVar) {
                return aVar;
            }
        } else {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            C1.N(obj);
        }
        Map map = (Map) obj;
        if (map.isEmpty()) {
            Log.d("SessionLifecycleClient", "Sessions SDK did not have any dependent SDKs register as dependencies. Events will not be sent.");
        } else {
            Collection collectionValues = map.values();
            if (collectionValues == null || !collectionValues.isEmpty()) {
                Iterator it = collectionValues.iterator();
                while (it.hasNext()) {
                    if (((k4.j) it.next()).f13867a.a()) {
                        ArrayList arrayList = this.f5733w;
                        C2.a aVar2 = this.f5732v;
                        for (Message message : B6.k.u0(B6.k.f0(B6.l.X(C2.a.b(aVar2, arrayList, 2), C2.a.b(aVar2, arrayList, 1))), new Z())) {
                            if (((Messenger) aVar2.f1157r) != null) {
                                try {
                                    Log.d("SessionLifecycleClient", "Sending lifecycle " + message.what + " to service");
                                    Messenger messenger = (Messenger) aVar2.f1157r;
                                    if (messenger != null) {
                                        messenger.send(message);
                                    }
                                } catch (RemoteException e8) {
                                    Log.w("SessionLifecycleClient", "Unable to deliver message: " + message.what, e8);
                                    aVar2.B(message);
                                }
                            } else {
                                aVar2.B(message);
                            }
                        }
                    }
                }
                Log.d("SessionLifecycleClient", "Data Collection is disabled for all subscribers. Skipping this Event");
            } else {
                Log.d("SessionLifecycleClient", "Data Collection is disabled for all subscribers. Skipping this Event");
            }
        }
        return A6.n.f457a;
    }
}
