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

204 lines
12 KiB
Java

package androidx.room;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import androidx.room.IMultiInstanceInvalidationService;
import androidx.room.InvalidationTracker;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: MultiInstanceInvalidationClient.kt */
@Metadata(d1 = {"\u0000h\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u0001B-\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\u0006\u0010\b\u001a\u00020\t\u0012\u0006\u0010\n\u001a\u00020\u000b¢\u0006\u0002\u0010\fJ\u0006\u00109\u001a\u00020:R\u0016\u0010\r\u001a\n \u000e*\u0004\u0018\u00010\u00030\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u000f\u001a\u00020\u0010¢\u0006\b\n\u0000\u001a\u0004\b\u0011\u0010\u0012R\u001a\u0010\u0013\u001a\u00020\u0014X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0015\u0010\u0016\"\u0004\b\u0017\u0010\u0018R\u0011\u0010\n\u001a\u00020\u000b¢\u0006\b\n\u0000\u001a\u0004\b\u0019\u0010\u001aR\u0011\u0010\b\u001a\u00020\\u0006\b\n\u0000\u001a\u0004\b\u001b\u0010\u001cR\u0011\u0010\u0004\u001a\u00020\u0005¢\u0006\b\n\u0000\u001a\u0004\b\u001d\u0010\u001eR\u001a\u0010\u001f\u001a\u00020 X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b!\u0010\"\"\u0004\b#\u0010$R\u0011\u0010%\u001a\u00020&¢\u0006\b\n\u0000\u001a\u0004\b'\u0010(R\u001c\u0010)\u001a\u0004\u0018\u00010*X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b+\u0010,\"\u0004\b-\u0010.R\u0011\u0010/\u001a\u000200¢\u0006\b\n\u0000\u001a\u0004\b1\u00102R\u0011\u00103\u001a\u00020&¢\u0006\b\n\u0000\u001a\u0004\b4\u0010(R\u0011\u00105\u001a\u000206¢\u0006\b\n\u0000\u001a\u0004\b7\u00108¨\u0006;"}, d2 = {"Landroidx/room/MultiInstanceInvalidationClient;", "", "context", "Landroid/content/Context;", "name", "", "serviceIntent", "Landroid/content/Intent;", "invalidationTracker", "Landroidx/room/InvalidationTracker;", "executor", "Ljava/util/concurrent/Executor;", "(Landroid/content/Context;Ljava/lang/String;Landroid/content/Intent;Landroidx/room/InvalidationTracker;Ljava/util/concurrent/Executor;)V", "appContext", "kotlin.jvm.PlatformType", "callback", "Landroidx/room/IMultiInstanceInvalidationCallback;", "getCallback", "()Landroidx/room/IMultiInstanceInvalidationCallback;", "clientId", "", "getClientId", "()I", "setClientId", "(I)V", "getExecutor", "()Ljava/util/concurrent/Executor;", "getInvalidationTracker", "()Landroidx/room/InvalidationTracker;", "getName", "()Ljava/lang/String;", "observer", "Landroidx/room/InvalidationTracker$Observer;", "getObserver", "()Landroidx/room/InvalidationTracker$Observer;", "setObserver", "(Landroidx/room/InvalidationTracker$Observer;)V", "removeObserverRunnable", "Ljava/lang/Runnable;", "getRemoveObserverRunnable", "()Ljava/lang/Runnable;", NotificationCompat.CATEGORY_SERVICE, "Landroidx/room/IMultiInstanceInvalidationService;", "getService", "()Landroidx/room/IMultiInstanceInvalidationService;", "setService", "(Landroidx/room/IMultiInstanceInvalidationService;)V", "serviceConnection", "Landroid/content/ServiceConnection;", "getServiceConnection", "()Landroid/content/ServiceConnection;", "setUpRunnable", "getSetUpRunnable", "stopped", "Ljava/util/concurrent/atomic/AtomicBoolean;", "getStopped", "()Ljava/util/concurrent/atomic/AtomicBoolean;", "stop", "", "room-runtime_release"}, k = 1, mv = {1, 7, 1}, xi = 48)
/* loaded from: classes2.dex */
public final class MultiInstanceInvalidationClient {
private final Context appContext;
private final IMultiInstanceInvalidationCallback callback;
private int clientId;
private final Executor executor;
private final InvalidationTracker invalidationTracker;
private final String name;
public InvalidationTracker.Observer observer;
private final Runnable removeObserverRunnable;
private IMultiInstanceInvalidationService service;
private final ServiceConnection serviceConnection;
private final Runnable setUpRunnable;
private final AtomicBoolean stopped;
public final IMultiInstanceInvalidationCallback getCallback() {
return this.callback;
}
public final int getClientId() {
return this.clientId;
}
public final Executor getExecutor() {
return this.executor;
}
public final InvalidationTracker getInvalidationTracker() {
return this.invalidationTracker;
}
public final String getName() {
return this.name;
}
public final Runnable getRemoveObserverRunnable() {
return this.removeObserverRunnable;
}
public final IMultiInstanceInvalidationService getService() {
return this.service;
}
public final ServiceConnection getServiceConnection() {
return this.serviceConnection;
}
public final Runnable getSetUpRunnable() {
return this.setUpRunnable;
}
public final AtomicBoolean getStopped() {
return this.stopped;
}
public final void setClientId(int i) {
this.clientId = i;
}
public final void setObserver(InvalidationTracker.Observer observer) {
Intrinsics.checkNotNullParameter(observer, "<set-?>");
this.observer = observer;
}
public final void setService(IMultiInstanceInvalidationService iMultiInstanceInvalidationService) {
this.service = iMultiInstanceInvalidationService;
}
public MultiInstanceInvalidationClient(Context context, String name, Intent serviceIntent, InvalidationTracker invalidationTracker, Executor executor) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(name, "name");
Intrinsics.checkNotNullParameter(serviceIntent, "serviceIntent");
Intrinsics.checkNotNullParameter(invalidationTracker, "invalidationTracker");
Intrinsics.checkNotNullParameter(executor, "executor");
this.name = name;
this.invalidationTracker = invalidationTracker;
this.executor = executor;
Context applicationContext = context.getApplicationContext();
this.appContext = applicationContext;
this.callback = new MultiInstanceInvalidationClient$callback$1(this);
this.stopped = new AtomicBoolean(false);
ServiceConnection serviceConnection = new ServiceConnection() { // from class: androidx.room.MultiInstanceInvalidationClient$serviceConnection$1
@Override // android.content.ServiceConnection
public void onServiceConnected(ComponentName name2, IBinder service) {
Intrinsics.checkNotNullParameter(name2, "name");
Intrinsics.checkNotNullParameter(service, "service");
MultiInstanceInvalidationClient.this.setService(IMultiInstanceInvalidationService.Stub.asInterface(service));
MultiInstanceInvalidationClient.this.getExecutor().execute(MultiInstanceInvalidationClient.this.getSetUpRunnable());
}
@Override // android.content.ServiceConnection
public void onServiceDisconnected(ComponentName name2) {
Intrinsics.checkNotNullParameter(name2, "name");
MultiInstanceInvalidationClient.this.getExecutor().execute(MultiInstanceInvalidationClient.this.getRemoveObserverRunnable());
MultiInstanceInvalidationClient.this.setService(null);
}
};
this.serviceConnection = serviceConnection;
this.setUpRunnable = new Runnable() { // from class: androidx.room.MultiInstanceInvalidationClient$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
MultiInstanceInvalidationClient.setUpRunnable$lambda$1(MultiInstanceInvalidationClient.this);
}
};
this.removeObserverRunnable = new Runnable() { // from class: androidx.room.MultiInstanceInvalidationClient$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
MultiInstanceInvalidationClient.removeObserverRunnable$lambda$2(MultiInstanceInvalidationClient.this);
}
};
Object[] array = invalidationTracker.getTableIdLookup$room_runtime_release().keySet().toArray(new String[0]);
Intrinsics.checkNotNull(array, "null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
setObserver(new InvalidationTracker.Observer((String[]) array) { // from class: androidx.room.MultiInstanceInvalidationClient.1
@Override // androidx.room.InvalidationTracker.Observer
public boolean isRemote$room_runtime_release() {
return true;
}
@Override // androidx.room.InvalidationTracker.Observer
public void onInvalidated(Set<String> tables) {
Intrinsics.checkNotNullParameter(tables, "tables");
if (MultiInstanceInvalidationClient.this.getStopped().get()) {
return;
}
try {
IMultiInstanceInvalidationService service = MultiInstanceInvalidationClient.this.getService();
if (service != null) {
int clientId = MultiInstanceInvalidationClient.this.getClientId();
Object[] array2 = tables.toArray(new String[0]);
Intrinsics.checkNotNull(array2, "null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
service.broadcastInvalidation(clientId, (String[]) array2);
}
} catch (RemoteException e) {
Log.w(Room.LOG_TAG, "Cannot broadcast invalidation", e);
}
}
});
applicationContext.bindService(serviceIntent, serviceConnection, 1);
}
public final InvalidationTracker.Observer getObserver() {
InvalidationTracker.Observer observer = this.observer;
if (observer != null) {
return observer;
}
Intrinsics.throwUninitializedPropertyAccessException("observer");
return null;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void setUpRunnable$lambda$1(MultiInstanceInvalidationClient this$0) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
try {
IMultiInstanceInvalidationService iMultiInstanceInvalidationService = this$0.service;
if (iMultiInstanceInvalidationService != null) {
this$0.clientId = iMultiInstanceInvalidationService.registerCallback(this$0.callback, this$0.name);
this$0.invalidationTracker.addObserver(this$0.getObserver());
}
} catch (RemoteException e) {
Log.w(Room.LOG_TAG, "Cannot register multi-instance invalidation callback", e);
}
}
/* JADX INFO: Access modifiers changed from: private */
public static final void removeObserverRunnable$lambda$2(MultiInstanceInvalidationClient this$0) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.invalidationTracker.removeObserver(this$0.getObserver());
}
public final void stop() {
if (this.stopped.compareAndSet(false, true)) {
this.invalidationTracker.removeObserver(getObserver());
try {
IMultiInstanceInvalidationService iMultiInstanceInvalidationService = this.service;
if (iMultiInstanceInvalidationService != null) {
iMultiInstanceInvalidationService.unregisterCallback(this.callback, this.clientId);
}
} catch (RemoteException e) {
Log.w(Room.LOG_TAG, "Cannot unregister multi-instance invalidation callback", e);
}
this.appContext.unbindService(this.serviceConnection);
}
}
}