244 lines
7.9 KiB
Java
244 lines
7.9 KiB
Java
|
package o;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.res.AssetManager;
|
||
|
import android.content.res.Resources;
|
||
|
import android.graphics.Typeface;
|
||
|
import android.graphics.fonts.FontVariationAxis;
|
||
|
import android.net.Uri;
|
||
|
import android.os.CancellationSignal;
|
||
|
import android.os.ParcelFileDescriptor;
|
||
|
import com.airbnb.deeplinkdispatch.base.MatchIndex;
|
||
|
import java.io.IOException;
|
||
|
import java.lang.reflect.Array;
|
||
|
import java.lang.reflect.Constructor;
|
||
|
import java.lang.reflect.InvocationTargetException;
|
||
|
import java.lang.reflect.Method;
|
||
|
import java.nio.ByteBuffer;
|
||
|
import java.util.Map;
|
||
|
import o.Szw;
|
||
|
import o.ubj;
|
||
|
|
||
|
/* renamed from: o.Usy, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes.dex */
|
||
|
public class C1060Usy extends vOO {
|
||
|
protected final Method a;
|
||
|
protected final Method b;
|
||
|
protected final Method c;
|
||
|
protected final Class<?> d;
|
||
|
protected final Method e;
|
||
|
protected final Constructor<?> h;
|
||
|
protected final Method j;
|
||
|
|
||
|
private boolean b() {
|
||
|
return this.a != null;
|
||
|
}
|
||
|
|
||
|
public C1060Usy() {
|
||
|
Class<?> cls;
|
||
|
Constructor<?> constructor;
|
||
|
Method method;
|
||
|
Method method2;
|
||
|
Method method3;
|
||
|
Method method4;
|
||
|
Method method5;
|
||
|
try {
|
||
|
cls = d();
|
||
|
constructor = c(cls);
|
||
|
method = e(cls);
|
||
|
method2 = d(cls);
|
||
|
method3 = g(cls);
|
||
|
method4 = b(cls);
|
||
|
method5 = a(cls);
|
||
|
} catch (ClassNotFoundException | NoSuchMethodException unused) {
|
||
|
cls = null;
|
||
|
constructor = null;
|
||
|
method = null;
|
||
|
method2 = null;
|
||
|
method3 = null;
|
||
|
method4 = null;
|
||
|
method5 = null;
|
||
|
}
|
||
|
this.d = cls;
|
||
|
this.h = constructor;
|
||
|
this.a = method;
|
||
|
this.e = method2;
|
||
|
this.j = method3;
|
||
|
this.c = method4;
|
||
|
this.b = method5;
|
||
|
}
|
||
|
|
||
|
private Object e() {
|
||
|
try {
|
||
|
return this.h.newInstance(new Object[0]);
|
||
|
} catch (IllegalAccessException | InstantiationException | InvocationTargetException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean oV_(Context context, Object obj, String str, int i, int i2, int i3, FontVariationAxis[] fontVariationAxisArr) {
|
||
|
try {
|
||
|
return ((Boolean) this.a.invoke(obj, context.getAssets(), str, 0, Boolean.FALSE, Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3), fontVariationAxisArr)).booleanValue();
|
||
|
} catch (IllegalAccessException | InvocationTargetException unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean b(Object obj, ByteBuffer byteBuffer, int i, int i2, int i3) {
|
||
|
try {
|
||
|
return ((Boolean) this.e.invoke(obj, byteBuffer, Integer.valueOf(i), null, Integer.valueOf(i2), Integer.valueOf(i3))).booleanValue();
|
||
|
} catch (IllegalAccessException | InvocationTargetException unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected Typeface pa_(Object obj) {
|
||
|
try {
|
||
|
Object newInstance = Array.newInstance(this.d, 1);
|
||
|
Array.set(newInstance, 0, obj);
|
||
|
return (Typeface) this.b.invoke(null, newInstance, -1, -1);
|
||
|
} catch (IllegalAccessException | InvocationTargetException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean a(Object obj) {
|
||
|
try {
|
||
|
return ((Boolean) this.j.invoke(obj, new Object[0])).booleanValue();
|
||
|
} catch (IllegalAccessException | InvocationTargetException unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void e(Object obj) {
|
||
|
try {
|
||
|
this.c.invoke(obj, new Object[0]);
|
||
|
} catch (IllegalAccessException | InvocationTargetException unused) {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.vOO, o.TMM
|
||
|
public Typeface pj_(Context context, Szw.IeS ieS, Resources resources, int i) {
|
||
|
if (!b()) {
|
||
|
return super.pj_(context, ieS, resources, i);
|
||
|
}
|
||
|
Object e = e();
|
||
|
if (e == null) {
|
||
|
return null;
|
||
|
}
|
||
|
for (Szw.LWm lWm : ieS.c()) {
|
||
|
if (!oV_(context, e, lWm.d(), lWm.e(), lWm.c(), lWm.i() ? 1 : 0, FontVariationAxis.fromFontVariationSettings(lWm.b()))) {
|
||
|
e(e);
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
if (a(e)) {
|
||
|
return pa_(e);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override // o.vOO, o.TMM
|
||
|
public Typeface pk_(Context context, CancellationSignal cancellationSignal, ubj.HBt[] hBtArr, int i) {
|
||
|
Typeface pa_;
|
||
|
if (hBtArr.length <= 0) {
|
||
|
return null;
|
||
|
}
|
||
|
if (!b()) {
|
||
|
ubj.HBt a = a(hBtArr, i);
|
||
|
try {
|
||
|
ParcelFileDescriptor openFileDescriptor = context.getContentResolver().openFileDescriptor(a.qG_(), MatchIndex.ROOT_VALUE, cancellationSignal);
|
||
|
if (openFileDescriptor == null) {
|
||
|
if (openFileDescriptor != null) {
|
||
|
openFileDescriptor.close();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
try {
|
||
|
Typeface build = new Typeface.Builder(openFileDescriptor.getFileDescriptor()).setWeight(a.c()).setItalic(a.e()).build();
|
||
|
if (openFileDescriptor != null) {
|
||
|
openFileDescriptor.close();
|
||
|
}
|
||
|
return build;
|
||
|
} finally {
|
||
|
}
|
||
|
} catch (IOException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
Map<Uri, ByteBuffer> pp_ = ioR.pp_(context, hBtArr, cancellationSignal);
|
||
|
Object e = e();
|
||
|
if (e == null) {
|
||
|
return null;
|
||
|
}
|
||
|
boolean z = false;
|
||
|
for (ubj.HBt hBt : hBtArr) {
|
||
|
ByteBuffer byteBuffer = pp_.get(hBt.qG_());
|
||
|
if (byteBuffer != null) {
|
||
|
if (!b(e, byteBuffer, hBt.b(), hBt.c(), hBt.e() ? 1 : 0)) {
|
||
|
e(e);
|
||
|
return null;
|
||
|
}
|
||
|
z = true;
|
||
|
}
|
||
|
}
|
||
|
if (!z) {
|
||
|
e(e);
|
||
|
return null;
|
||
|
}
|
||
|
if (a(e) && (pa_ = pa_(e)) != null) {
|
||
|
return Typeface.create(pa_, i);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override // o.TMM
|
||
|
public Typeface pm_(Context context, Resources resources, int i, String str, int i2) {
|
||
|
if (!b()) {
|
||
|
return super.pm_(context, resources, i, str, i2);
|
||
|
}
|
||
|
Object e = e();
|
||
|
if (e == null) {
|
||
|
return null;
|
||
|
}
|
||
|
if (!oV_(context, e, str, 0, -1, -1, null)) {
|
||
|
e(e);
|
||
|
return null;
|
||
|
}
|
||
|
if (a(e)) {
|
||
|
return pa_(e);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
protected Class<?> d() throws ClassNotFoundException {
|
||
|
return Class.forName("android.graphics.FontFamily");
|
||
|
}
|
||
|
|
||
|
protected Constructor<?> c(Class<?> cls) throws NoSuchMethodException {
|
||
|
return cls.getConstructor(new Class[0]);
|
||
|
}
|
||
|
|
||
|
protected Method e(Class<?> cls) throws NoSuchMethodException {
|
||
|
return cls.getMethod("addFontFromAssetManager", AssetManager.class, String.class, Integer.TYPE, Boolean.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, FontVariationAxis[].class);
|
||
|
}
|
||
|
|
||
|
protected Method d(Class<?> cls) throws NoSuchMethodException {
|
||
|
return cls.getMethod("addFontFromBuffer", ByteBuffer.class, Integer.TYPE, FontVariationAxis[].class, Integer.TYPE, Integer.TYPE);
|
||
|
}
|
||
|
|
||
|
protected Method g(Class<?> cls) throws NoSuchMethodException {
|
||
|
return cls.getMethod("freeze", new Class[0]);
|
||
|
}
|
||
|
|
||
|
protected Method b(Class<?> cls) throws NoSuchMethodException {
|
||
|
return cls.getMethod("abortCreation", new Class[0]);
|
||
|
}
|
||
|
|
||
|
protected Method a(Class<?> cls) throws NoSuchMethodException {
|
||
|
Method declaredMethod = Typeface.class.getDeclaredMethod("createFromFamiliesWithDefault", Array.newInstance(cls, 1).getClass(), Integer.TYPE, Integer.TYPE);
|
||
|
declaredMethod.setAccessible(true);
|
||
|
return declaredMethod;
|
||
|
}
|
||
|
}
|