Rabbit-R1/android (non root)/java/sources/androidx/window/embedding/ExtensionEmbeddingBackend.java
2024-05-21 17:08:36 -04:00

297 lines
19 KiB
Java

package androidx.window.embedding;
import android.app.Activity;
import android.util.Log;
import androidx.core.util.Consumer;
import androidx.window.embedding.EmbeddingInterfaceCompat;
import androidx.window.embedding.ExtensionEmbeddingBackend;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Executor;
import java.util.concurrent.locks.ReentrantLock;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: ExtensionEmbeddingBackend.kt */
@Metadata(d1 = {"\u0000^\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\"\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\t\b\u0001\u0018\u0000 )2\u00020\u0001:\u0003)*+B\u0011\b\u0007\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003¢\u0006\u0002\u0010\u0004J\u000e\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u00130\u0015H\u0016J\b\u0010\u0016\u001a\u00020\u0017H\u0016J\u0010\u0010\u0018\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u0013H\u0016J,\u0010\u001b\u001a\u00020\u00192\u0006\u0010\u001c\u001a\u00020\u001d2\u0006\u0010\u001e\u001a\u00020\u001f2\u0012\u0010 \u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020#0\"0!H\u0016J\u0016\u0010$\u001a\u00020\u00192\f\u0010%\u001a\b\u0012\u0004\u0012\u00020\u00130\u0015H\u0016J\u0010\u0010&\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u0013H\u0016J\u001c\u0010'\u001a\u00020\u00192\u0012\u0010(\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020#0\"0!H\u0016R \u0010\u0002\u001a\u0004\u0018\u00010\u00038\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0005\u0010\u0006\"\u0004\b\u0007\u0010\u0004R\"\u0010\b\u001a\b\u0012\u0004\u0012\u00020\n0\t8\u0006X\u0087\u0004¢\u0006\u000e\n\u0000\u0012\u0004\b\u000b\u0010\f\u001a\u0004\b\r\u0010\u000eR\u0012\u0010\u000f\u001a\u00060\u0010R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00130\u0012X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006,"}, d2 = {"Landroidx/window/embedding/ExtensionEmbeddingBackend;", "Landroidx/window/embedding/EmbeddingBackend;", "embeddingExtension", "Landroidx/window/embedding/EmbeddingInterfaceCompat;", "(Landroidx/window/embedding/EmbeddingInterfaceCompat;)V", "getEmbeddingExtension", "()Landroidx/window/embedding/EmbeddingInterfaceCompat;", "setEmbeddingExtension", "splitChangeCallbacks", "Ljava/util/concurrent/CopyOnWriteArrayList;", "Landroidx/window/embedding/ExtensionEmbeddingBackend$SplitListenerWrapper;", "getSplitChangeCallbacks$annotations", "()V", "getSplitChangeCallbacks", "()Ljava/util/concurrent/CopyOnWriteArrayList;", "splitInfoEmbeddingCallback", "Landroidx/window/embedding/ExtensionEmbeddingBackend$EmbeddingCallbackImpl;", "splitRules", "Ljava/util/concurrent/CopyOnWriteArraySet;", "Landroidx/window/embedding/EmbeddingRule;", "getSplitRules", "", "isSplitSupported", "", "registerRule", "", "rule", "registerSplitListenerForActivity", "activity", "Landroid/app/Activity;", "executor", "Ljava/util/concurrent/Executor;", "callback", "Landroidx/core/util/Consumer;", "", "Landroidx/window/embedding/SplitInfo;", "setSplitRules", "rules", "unregisterRule", "unregisterSplitListenerForActivity", "consumer", "Companion", "EmbeddingCallbackImpl", "SplitListenerWrapper", "window_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
/* loaded from: classes2.dex */
public final class ExtensionEmbeddingBackend implements EmbeddingBackend {
private static final String TAG = "EmbeddingBackend";
private static volatile ExtensionEmbeddingBackend globalInstance;
private EmbeddingInterfaceCompat embeddingExtension;
private final CopyOnWriteArrayList<SplitListenerWrapper> splitChangeCallbacks;
private final EmbeddingCallbackImpl splitInfoEmbeddingCallback;
private final CopyOnWriteArraySet<EmbeddingRule> splitRules;
/* renamed from: Companion, reason: from kotlin metadata */
public static final Companion INSTANCE = new Companion(null);
private static final ReentrantLock globalLock = new ReentrantLock();
public static /* synthetic */ void getSplitChangeCallbacks$annotations() {
}
public final EmbeddingInterfaceCompat getEmbeddingExtension() {
return this.embeddingExtension;
}
public final CopyOnWriteArrayList<SplitListenerWrapper> getSplitChangeCallbacks() {
return this.splitChangeCallbacks;
}
@Override // androidx.window.embedding.EmbeddingBackend
public boolean isSplitSupported() {
return this.embeddingExtension != null;
}
public final void setEmbeddingExtension(EmbeddingInterfaceCompat embeddingInterfaceCompat) {
this.embeddingExtension = embeddingInterfaceCompat;
}
public ExtensionEmbeddingBackend(EmbeddingInterfaceCompat embeddingInterfaceCompat) {
this.embeddingExtension = embeddingInterfaceCompat;
EmbeddingCallbackImpl embeddingCallbackImpl = new EmbeddingCallbackImpl(this);
this.splitInfoEmbeddingCallback = embeddingCallbackImpl;
this.splitChangeCallbacks = new CopyOnWriteArrayList<>();
EmbeddingInterfaceCompat embeddingInterfaceCompat2 = this.embeddingExtension;
if (embeddingInterfaceCompat2 != null) {
embeddingInterfaceCompat2.setEmbeddingCallback(embeddingCallbackImpl);
}
this.splitRules = new CopyOnWriteArraySet<>();
}
/* compiled from: ExtensionEmbeddingBackend.kt */
@Metadata(d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0006\u0010\t\u001a\u00020\u0006J\n\u0010\n\u001a\u0004\u0018\u00010\u000bH\u0002J\u0017\u0010\f\u001a\u00020\r2\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fH\u0007¢\u0006\u0002\u0010\u0010R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u0010\u0010\u0005\u001a\u0004\u0018\u00010\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0011"}, d2 = {"Landroidx/window/embedding/ExtensionEmbeddingBackend$Companion;", "", "()V", "TAG", "", "globalInstance", "Landroidx/window/embedding/ExtensionEmbeddingBackend;", "globalLock", "Ljava/util/concurrent/locks/ReentrantLock;", "getInstance", "initAndVerifyEmbeddingExtension", "Landroidx/window/embedding/EmbeddingInterfaceCompat;", "isExtensionVersionSupported", "", "extensionVersion", "", "(Ljava/lang/Integer;)Z", "window_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
/* loaded from: classes2.dex */
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final ExtensionEmbeddingBackend getInstance() {
if (ExtensionEmbeddingBackend.globalInstance == null) {
ReentrantLock reentrantLock = ExtensionEmbeddingBackend.globalLock;
reentrantLock.lock();
try {
if (ExtensionEmbeddingBackend.globalInstance == null) {
EmbeddingInterfaceCompat initAndVerifyEmbeddingExtension = ExtensionEmbeddingBackend.INSTANCE.initAndVerifyEmbeddingExtension();
Companion companion = ExtensionEmbeddingBackend.INSTANCE;
ExtensionEmbeddingBackend.globalInstance = new ExtensionEmbeddingBackend(initAndVerifyEmbeddingExtension);
}
Unit unit = Unit.INSTANCE;
} finally {
reentrantLock.unlock();
}
}
ExtensionEmbeddingBackend extensionEmbeddingBackend = ExtensionEmbeddingBackend.globalInstance;
Intrinsics.checkNotNull(extensionEmbeddingBackend);
return extensionEmbeddingBackend;
}
private final EmbeddingInterfaceCompat initAndVerifyEmbeddingExtension() {
EmbeddingCompat embeddingCompat = null;
try {
if (isExtensionVersionSupported(EmbeddingCompat.INSTANCE.getExtensionApiLevel()) && EmbeddingCompat.INSTANCE.isEmbeddingAvailable()) {
embeddingCompat = new EmbeddingCompat();
}
} catch (Throwable th) {
Log.d(ExtensionEmbeddingBackend.TAG, Intrinsics.stringPlus("Failed to load embedding extension: ", th));
}
if (embeddingCompat == null) {
Log.d(ExtensionEmbeddingBackend.TAG, "No supported embedding extension found");
}
return embeddingCompat;
}
public final boolean isExtensionVersionSupported(Integer extensionVersion) {
return extensionVersion != null && extensionVersion.intValue() >= 1;
}
}
@Override // androidx.window.embedding.EmbeddingBackend
public Set<EmbeddingRule> getSplitRules() {
return this.splitRules;
}
@Override // androidx.window.embedding.EmbeddingBackend
public void setSplitRules(Set<? extends EmbeddingRule> rules) {
Intrinsics.checkNotNullParameter(rules, "rules");
this.splitRules.clear();
this.splitRules.addAll(rules);
EmbeddingInterfaceCompat embeddingInterfaceCompat = this.embeddingExtension;
if (embeddingInterfaceCompat == null) {
return;
}
embeddingInterfaceCompat.setSplitRules(this.splitRules);
}
@Override // androidx.window.embedding.EmbeddingBackend
public void registerRule(EmbeddingRule rule) {
Intrinsics.checkNotNullParameter(rule, "rule");
if (this.splitRules.contains(rule)) {
return;
}
this.splitRules.add(rule);
EmbeddingInterfaceCompat embeddingInterfaceCompat = this.embeddingExtension;
if (embeddingInterfaceCompat == null) {
return;
}
embeddingInterfaceCompat.setSplitRules(this.splitRules);
}
@Override // androidx.window.embedding.EmbeddingBackend
public void unregisterRule(EmbeddingRule rule) {
Intrinsics.checkNotNullParameter(rule, "rule");
if (this.splitRules.contains(rule)) {
this.splitRules.remove(rule);
EmbeddingInterfaceCompat embeddingInterfaceCompat = this.embeddingExtension;
if (embeddingInterfaceCompat == null) {
return;
}
embeddingInterfaceCompat.setSplitRules(this.splitRules);
}
}
/* compiled from: ExtensionEmbeddingBackend.kt */
@Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0002\b\u0000\u0018\u00002\u00020\u0001B)\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0012\u0010\u0006\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\t0\b0\u0007¢\u0006\u0002\u0010\nJ\u0014\u0010\u000e\u001a\u00020\u000f2\f\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\t0\bR\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u001d\u0010\u0006\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\t0\b0\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\r\u001a\n\u0012\u0004\u0012\u00020\t\u0018\u00010\bX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u0011"}, d2 = {"Landroidx/window/embedding/ExtensionEmbeddingBackend$SplitListenerWrapper;", "", "activity", "Landroid/app/Activity;", "executor", "Ljava/util/concurrent/Executor;", "callback", "Landroidx/core/util/Consumer;", "", "Landroidx/window/embedding/SplitInfo;", "(Landroid/app/Activity;Ljava/util/concurrent/Executor;Landroidx/core/util/Consumer;)V", "getCallback", "()Landroidx/core/util/Consumer;", "lastValue", "accept", "", "splitInfoList", "window_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
/* loaded from: classes2.dex */
public static final class SplitListenerWrapper {
private final Activity activity;
private final Consumer<List<SplitInfo>> callback;
private final Executor executor;
private List<SplitInfo> lastValue;
public final Consumer<List<SplitInfo>> getCallback() {
return this.callback;
}
public SplitListenerWrapper(Activity activity, Executor executor, Consumer<List<SplitInfo>> callback) {
Intrinsics.checkNotNullParameter(activity, "activity");
Intrinsics.checkNotNullParameter(executor, "executor");
Intrinsics.checkNotNullParameter(callback, "callback");
this.activity = activity;
this.executor = executor;
this.callback = callback;
}
public final void accept(List<SplitInfo> splitInfoList) {
Intrinsics.checkNotNullParameter(splitInfoList, "splitInfoList");
ArrayList arrayList = new ArrayList();
for (Object obj : splitInfoList) {
if (((SplitInfo) obj).contains(this.activity)) {
arrayList.add(obj);
}
}
final ArrayList arrayList2 = arrayList;
if (Intrinsics.areEqual(arrayList2, this.lastValue)) {
return;
}
this.lastValue = arrayList2;
this.executor.execute(new Runnable() { // from class: androidx.window.embedding.ExtensionEmbeddingBackend$SplitListenerWrapper$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
ExtensionEmbeddingBackend.SplitListenerWrapper.m5329accept$lambda1(ExtensionEmbeddingBackend.SplitListenerWrapper.this, arrayList2);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: accept$lambda-1, reason: not valid java name */
public static final void m5329accept$lambda1(SplitListenerWrapper this$0, List splitsWithActivity) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(splitsWithActivity, "$splitsWithActivity");
this$0.callback.accept(splitsWithActivity);
}
}
@Override // androidx.window.embedding.EmbeddingBackend
public void registerSplitListenerForActivity(Activity activity, Executor executor, Consumer<List<SplitInfo>> callback) {
Intrinsics.checkNotNullParameter(activity, "activity");
Intrinsics.checkNotNullParameter(executor, "executor");
Intrinsics.checkNotNullParameter(callback, "callback");
ReentrantLock reentrantLock = globalLock;
reentrantLock.lock();
try {
if (getEmbeddingExtension() == null) {
Log.v(TAG, "Extension not loaded, skipping callback registration.");
callback.accept(CollectionsKt.emptyList());
return;
}
SplitListenerWrapper splitListenerWrapper = new SplitListenerWrapper(activity, executor, callback);
getSplitChangeCallbacks().add(splitListenerWrapper);
if (this.splitInfoEmbeddingCallback.getLastInfo() != null) {
List<SplitInfo> lastInfo = this.splitInfoEmbeddingCallback.getLastInfo();
Intrinsics.checkNotNull(lastInfo);
splitListenerWrapper.accept(lastInfo);
} else {
splitListenerWrapper.accept(CollectionsKt.emptyList());
}
Unit unit = Unit.INSTANCE;
} finally {
reentrantLock.unlock();
}
}
@Override // androidx.window.embedding.EmbeddingBackend
public void unregisterSplitListenerForActivity(Consumer<List<SplitInfo>> consumer) {
Intrinsics.checkNotNullParameter(consumer, "consumer");
ReentrantLock reentrantLock = globalLock;
reentrantLock.lock();
try {
Iterator<SplitListenerWrapper> it = getSplitChangeCallbacks().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
SplitListenerWrapper next = it.next();
if (Intrinsics.areEqual(next.getCallback(), consumer)) {
getSplitChangeCallbacks().remove(next);
break;
}
}
Unit unit = Unit.INSTANCE;
} finally {
reentrantLock.unlock();
}
}
/* compiled from: ExtensionEmbeddingBackend.kt */
@Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0002\b\u0080\u0004\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0016\u0010\n\u001a\u00020\u000b2\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u00050\u0004H\u0016R\"\u0010\u0003\u001a\n\u0012\u0004\u0012\u00020\u0005\u0018\u00010\u0004X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0006\u0010\u0007\"\u0004\b\b\u0010\\u0006\r"}, d2 = {"Landroidx/window/embedding/ExtensionEmbeddingBackend$EmbeddingCallbackImpl;", "Landroidx/window/embedding/EmbeddingInterfaceCompat$EmbeddingCallbackInterface;", "(Landroidx/window/embedding/ExtensionEmbeddingBackend;)V", "lastInfo", "", "Landroidx/window/embedding/SplitInfo;", "getLastInfo", "()Ljava/util/List;", "setLastInfo", "(Ljava/util/List;)V", "onSplitInfoChanged", "", "splitInfo", "window_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
/* loaded from: classes2.dex */
public final class EmbeddingCallbackImpl implements EmbeddingInterfaceCompat.EmbeddingCallbackInterface {
private List<SplitInfo> lastInfo;
final /* synthetic */ ExtensionEmbeddingBackend this$0;
public final List<SplitInfo> getLastInfo() {
return this.lastInfo;
}
public final void setLastInfo(List<SplitInfo> list) {
this.lastInfo = list;
}
public EmbeddingCallbackImpl(ExtensionEmbeddingBackend this$0) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this.this$0 = this$0;
}
@Override // androidx.window.embedding.EmbeddingInterfaceCompat.EmbeddingCallbackInterface
public void onSplitInfoChanged(List<SplitInfo> splitInfo) {
Intrinsics.checkNotNullParameter(splitInfo, "splitInfo");
this.lastInfo = splitInfo;
Iterator<SplitListenerWrapper> it = this.this$0.getSplitChangeCallbacks().iterator();
while (it.hasNext()) {
it.next().accept(splitInfo);
}
}
}
}