160 lines
4.9 KiB
Java
160 lines
4.9 KiB
Java
package androidx.versionedparcelable;
|
|
|
|
import android.os.Parcelable;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class VersionedParcel {
|
|
|
|
public static class ParcelException extends RuntimeException {
|
|
public ParcelException(Throwable th) {
|
|
super(th);
|
|
}
|
|
}
|
|
|
|
private void c(VersionedParcelable versionedParcelable) {
|
|
try {
|
|
a(a((Class<? extends VersionedParcelable>) versionedParcelable.getClass()).getName());
|
|
} catch (ClassNotFoundException e) {
|
|
throw new RuntimeException(versionedParcelable.getClass().getSimpleName() + " does not have a Parcelizer", e);
|
|
}
|
|
}
|
|
|
|
public int a(int i, int i2) {
|
|
return !a(i2) ? i : e();
|
|
}
|
|
|
|
protected abstract void a();
|
|
|
|
protected abstract void a(Parcelable parcelable);
|
|
|
|
protected abstract void a(String str);
|
|
|
|
public void a(boolean z, boolean z2) {
|
|
}
|
|
|
|
protected abstract void a(byte[] bArr);
|
|
|
|
protected abstract boolean a(int i);
|
|
|
|
protected abstract VersionedParcel b();
|
|
|
|
protected abstract void b(int i);
|
|
|
|
public void b(byte[] bArr, int i) {
|
|
b(i);
|
|
a(bArr);
|
|
}
|
|
|
|
protected abstract void c(int i);
|
|
|
|
public boolean c() {
|
|
return false;
|
|
}
|
|
|
|
protected abstract byte[] d();
|
|
|
|
protected abstract int e();
|
|
|
|
protected abstract <T extends Parcelable> T f();
|
|
|
|
protected abstract String g();
|
|
|
|
protected <T extends VersionedParcelable> T h() {
|
|
String g = g();
|
|
if (g == null) {
|
|
return null;
|
|
}
|
|
return (T) a(g, b());
|
|
}
|
|
|
|
public String a(String str, int i) {
|
|
return !a(i) ? str : g();
|
|
}
|
|
|
|
public void b(int i, int i2) {
|
|
b(i2);
|
|
c(i);
|
|
}
|
|
|
|
public byte[] a(byte[] bArr, int i) {
|
|
return !a(i) ? bArr : d();
|
|
}
|
|
|
|
public void b(String str, int i) {
|
|
b(i);
|
|
a(str);
|
|
}
|
|
|
|
public <T extends Parcelable> T a(T t, int i) {
|
|
return !a(i) ? t : (T) f();
|
|
}
|
|
|
|
public void b(Parcelable parcelable, int i) {
|
|
b(i);
|
|
a(parcelable);
|
|
}
|
|
|
|
protected void a(VersionedParcelable versionedParcelable) {
|
|
if (versionedParcelable == null) {
|
|
a((String) null);
|
|
return;
|
|
}
|
|
c(versionedParcelable);
|
|
VersionedParcel b = b();
|
|
a(versionedParcelable, b);
|
|
b.a();
|
|
}
|
|
|
|
public void b(VersionedParcelable versionedParcelable, int i) {
|
|
b(i);
|
|
a(versionedParcelable);
|
|
}
|
|
|
|
private static <T extends VersionedParcelable> Class b(T t) throws ClassNotFoundException {
|
|
return a((Class<? extends VersionedParcelable>) t.getClass());
|
|
}
|
|
|
|
public <T extends VersionedParcelable> T a(T t, int i) {
|
|
return !a(i) ? t : (T) h();
|
|
}
|
|
|
|
protected static <T extends VersionedParcelable> T a(String str, VersionedParcel versionedParcel) {
|
|
try {
|
|
return (T) Class.forName(str, true, VersionedParcel.class.getClassLoader()).getDeclaredMethod("read", VersionedParcel.class).invoke(null, versionedParcel);
|
|
} catch (ClassNotFoundException e) {
|
|
throw new RuntimeException("VersionedParcel encountered ClassNotFoundException", e);
|
|
} catch (IllegalAccessException e2) {
|
|
throw new RuntimeException("VersionedParcel encountered IllegalAccessException", e2);
|
|
} catch (NoSuchMethodException e3) {
|
|
throw new RuntimeException("VersionedParcel encountered NoSuchMethodException", e3);
|
|
} catch (InvocationTargetException e4) {
|
|
if (e4.getCause() instanceof RuntimeException) {
|
|
throw ((RuntimeException) e4.getCause());
|
|
}
|
|
throw new RuntimeException("VersionedParcel encountered InvocationTargetException", e4);
|
|
}
|
|
}
|
|
|
|
protected static <T extends VersionedParcelable> void a(T t, VersionedParcel versionedParcel) {
|
|
try {
|
|
b(t).getDeclaredMethod("write", t.getClass(), VersionedParcel.class).invoke(null, t, versionedParcel);
|
|
} catch (ClassNotFoundException e) {
|
|
throw new RuntimeException("VersionedParcel encountered ClassNotFoundException", e);
|
|
} catch (IllegalAccessException e2) {
|
|
throw new RuntimeException("VersionedParcel encountered IllegalAccessException", e2);
|
|
} catch (NoSuchMethodException e3) {
|
|
throw new RuntimeException("VersionedParcel encountered NoSuchMethodException", e3);
|
|
} catch (InvocationTargetException e4) {
|
|
if (e4.getCause() instanceof RuntimeException) {
|
|
throw ((RuntimeException) e4.getCause());
|
|
}
|
|
throw new RuntimeException("VersionedParcel encountered InvocationTargetException", e4);
|
|
}
|
|
}
|
|
|
|
private static Class a(Class<? extends VersionedParcelable> cls) throws ClassNotFoundException {
|
|
return Class.forName(String.format("%s.%sParcelizer", cls.getPackage().getName(), cls.getSimpleName()), false, cls.getClassLoader());
|
|
}
|
|
}
|