package o; import android.app.Activity; import androidx.window.extensions.layout.WindowLayoutComponent; import androidx.window.extensions.layout.WindowLayoutInfo; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; /* loaded from: classes.dex */ public final class IKu implements InterfaceC0372FdA { private final Map b; private final Map, Activity> c; private final ReentrantLock d; private final WindowLayoutComponent e; public IKu(WindowLayoutComponent windowLayoutComponent) { C14957gcv.e(windowLayoutComponent, ""); this.e = windowLayoutComponent; this.d = new ReentrantLock(); this.b = new LinkedHashMap(); this.c = new LinkedHashMap(); } @Override // o.InterfaceC0372FdA public final void CW_(Activity activity, Executor executor, QUU quu) { C14866gag c14866gag; C14957gcv.e(activity, ""); C14957gcv.e(executor, ""); C14957gcv.e(quu, ""); ReentrantLock reentrantLock = this.d; reentrantLock.lock(); try { HBt hBt = this.b.get(activity); if (hBt == null) { c14866gag = null; } else { hBt.d(quu); this.c.put(quu, activity); c14866gag = C14866gag.c; } if (c14866gag == null) { IKu iKu = this; HBt hBt2 = new HBt(activity); this.b.put(activity, hBt2); this.c.put(quu, activity); hBt2.d(quu); this.e.addWindowLayoutInfoListener(activity, hBt2); } C14866gag c14866gag2 = C14866gag.c; } finally { reentrantLock.unlock(); } } @Override // o.InterfaceC0372FdA public final void a(QUU quu) { C14957gcv.e(quu, ""); ReentrantLock reentrantLock = this.d; reentrantLock.lock(); try { Activity activity = this.c.get(quu); if (activity == null) { return; } HBt hBt = this.b.get(activity); if (hBt == null) { return; } C14957gcv.e(quu, ""); reentrantLock = hBt.e; reentrantLock.lock(); hBt.d.remove(quu); reentrantLock.unlock(); if (hBt.d.isEmpty()) { this.e.removeWindowLayoutInfoListener(hBt); } C14866gag c14866gag = C14866gag.c; } catch (Throwable th) { throw th; } finally { reentrantLock.unlock(); } } /* loaded from: classes.dex */ static final class HBt implements Consumer { private final Activity a; private oEt b; final Set> d; final ReentrantLock e; public HBt(Activity activity) { C14957gcv.e(activity, ""); this.a = activity; this.e = new ReentrantLock(); this.d = new LinkedHashSet(); } @Override // java.util.function.Consumer public final /* synthetic */ void accept(WindowLayoutInfo windowLayoutInfo) { WindowLayoutInfo windowLayoutInfo2 = windowLayoutInfo; C14957gcv.e(windowLayoutInfo2, ""); ReentrantLock reentrantLock = this.e; reentrantLock.lock(); try { C11203eas c11203eas = C11203eas.d; this.b = C11203eas.CK_(this.a, windowLayoutInfo2); Iterator it = this.d.iterator(); while (it.hasNext()) { ((QUU) it.next()).accept(this.b); } C14866gag c14866gag = C14866gag.c; } finally { reentrantLock.unlock(); } } public final void d(QUU quu) { C14957gcv.e(quu, ""); ReentrantLock reentrantLock = this.e; reentrantLock.lock(); try { oEt oet = this.b; if (oet != null) { quu.accept(oet); } this.d.add(quu); } finally { reentrantLock.unlock(); } } } }