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

82 lines
2.7 KiB
Java

package androidx.media3.common;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.Util;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.List;
/* loaded from: classes2.dex */
public final class BundleListRetriever extends Binder {
private static final int REPLY_BREAK = 2;
private static final int REPLY_CONTINUE = 1;
private static final int REPLY_END_OF_LIST = 0;
private static final int SUGGESTED_MAX_IPC_SIZE;
private final ImmutableList<Bundle> list;
static {
SUGGESTED_MAX_IPC_SIZE = Util.SDK_INT >= 30 ? IBinder.getSuggestedMaxIpcSizeBytes() : 65536;
}
public BundleListRetriever(List<Bundle> list) {
this.list = ImmutableList.copyOf((Collection) list);
}
@Override // android.os.Binder
protected boolean onTransact(int i, Parcel parcel, Parcel parcel2, int i2) throws RemoteException {
if (i != 1) {
return super.onTransact(i, parcel, parcel2, i2);
}
if (parcel2 == null) {
return false;
}
int size = this.list.size();
int readInt = parcel.readInt();
while (readInt < size && parcel2.dataSize() < SUGGESTED_MAX_IPC_SIZE) {
parcel2.writeInt(1);
parcel2.writeBundle(this.list.get(readInt));
readInt++;
}
parcel2.writeInt(readInt < size ? 2 : 0);
return true;
}
public static ImmutableList<Bundle> getList(IBinder iBinder) {
int readInt;
ImmutableList.Builder builder = ImmutableList.builder();
int i = 0;
int i2 = 1;
while (i2 != 0) {
Parcel obtain = Parcel.obtain();
Parcel obtain2 = Parcel.obtain();
try {
obtain.writeInt(i);
try {
iBinder.transact(1, obtain, obtain2, 0);
while (true) {
readInt = obtain2.readInt();
if (readInt == 1) {
builder.add((ImmutableList.Builder) Assertions.checkNotNull(obtain2.readBundle()));
i++;
}
}
obtain2.recycle();
obtain.recycle();
i2 = readInt;
} catch (RemoteException e) {
throw new RuntimeException(e);
}
} catch (Throwable th) {
obtain2.recycle();
obtain.recycle();
throw th;
}
}
return builder.build();
}
}