package com.google.android.gms.internal.vision; import com.google.android.libraries.places.api.model.PlaceTypes; import com.google.common.primitives.UnsignedBytes; import java.lang.reflect.Field; import java.nio.Buffer; import java.nio.ByteBuffer; import java.security.AccessController; import java.util.logging.Level; import java.util.logging.Logger; import libcore.io.Memory; import sun.misc.Unsafe; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class zziu { private static final Logger logger = Logger.getLogger(zziu.class.getName()); private static final boolean zzaaz; private static final boolean zzaba; private static final zzd zzabb; private static final boolean zzabc; private static final long zzabd; private static final long zzabe; private static final long zzabf; private static final long zzabg; private static final long zzabh; private static final long zzabi; private static final long zzabj; private static final long zzabk; private static final long zzabl; private static final long zzabm; private static final long zzabn; private static final long zzabo; private static final long zzabp; private static final long zzabq; private static final boolean zzabr; private static final Class zzrm; private static final boolean zzsr; private static final Unsafe zzzc; private zziu() { } /* loaded from: classes2.dex */ static final class zzb extends zzd { zzb(Unsafe unsafe) { super(unsafe); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(long j, byte b) { Memory.pokeByte(j, b); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final byte zzy(Object obj, long j) { if (zziu.zzabr) { return zziu.zzq(obj, j); } return zziu.zzr(obj, j); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zze(Object obj, long j, byte b) { if (zziu.zzabr) { zziu.zza(obj, j, b); } else { zziu.zzb(obj, j, b); } } @Override // com.google.android.gms.internal.vision.zziu.zzd public final boolean zzm(Object obj, long j) { if (zziu.zzabr) { return zziu.zzs(obj, j); } return zziu.zzt(obj, j); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, boolean z) { if (zziu.zzabr) { zziu.zzb(obj, j, z); } else { zziu.zzc(obj, j, z); } } @Override // com.google.android.gms.internal.vision.zziu.zzd public final float zzn(Object obj, long j) { return Float.intBitsToFloat(zzk(obj, j)); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, float f) { zzb(obj, j, Float.floatToIntBits(f)); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final double zzo(Object obj, long j) { return Double.longBitsToDouble(zzl(obj, j)); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, double d) { zza(obj, j, Double.doubleToLongBits(d)); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(byte[] bArr, long j, long j2, long j3) { Memory.pokeByteArray(j2, bArr, (int) j, (int) j3); } } /* loaded from: classes2.dex */ static final class zzc extends zzd { zzc(Unsafe unsafe) { super(unsafe); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(long j, byte b) { this.zzabs.putByte(j, b); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final byte zzy(Object obj, long j) { return this.zzabs.getByte(obj, j); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zze(Object obj, long j, byte b) { this.zzabs.putByte(obj, j, b); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final boolean zzm(Object obj, long j) { return this.zzabs.getBoolean(obj, j); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, boolean z) { this.zzabs.putBoolean(obj, j, z); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final float zzn(Object obj, long j) { return this.zzabs.getFloat(obj, j); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, float f) { this.zzabs.putFloat(obj, j, f); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final double zzo(Object obj, long j) { return this.zzabs.getDouble(obj, j); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, double d) { this.zzabs.putDouble(obj, j, d); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(byte[] bArr, long j, long j2, long j3) { this.zzabs.copyMemory(bArr, zziu.zzabd + j, (Object) null, j2, j3); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static abstract class zzd { Unsafe zzabs; zzd(Unsafe unsafe) { this.zzabs = unsafe; } public abstract void zza(long j, byte b); public abstract void zza(Object obj, long j, double d); public abstract void zza(Object obj, long j, float f); public abstract void zza(Object obj, long j, boolean z); public abstract void zza(byte[] bArr, long j, long j2, long j3); public abstract void zze(Object obj, long j, byte b); public abstract boolean zzm(Object obj, long j); public abstract float zzn(Object obj, long j); public abstract double zzo(Object obj, long j); public abstract byte zzy(Object obj, long j); public final int zzk(Object obj, long j) { return this.zzabs.getInt(obj, j); } public final void zzb(Object obj, long j, int i) { this.zzabs.putInt(obj, j, i); } public final long zzl(Object obj, long j) { return this.zzabs.getLong(obj, j); } public final void zza(Object obj, long j, long j2) { this.zzabs.putLong(obj, j, j2); } } /* loaded from: classes2.dex */ static final class zza extends zzd { zza(Unsafe unsafe) { super(unsafe); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(long j, byte b) { Memory.pokeByte((int) j, b); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final byte zzy(Object obj, long j) { if (zziu.zzabr) { return zziu.zzq(obj, j); } return zziu.zzr(obj, j); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zze(Object obj, long j, byte b) { if (zziu.zzabr) { zziu.zza(obj, j, b); } else { zziu.zzb(obj, j, b); } } @Override // com.google.android.gms.internal.vision.zziu.zzd public final boolean zzm(Object obj, long j) { if (zziu.zzabr) { return zziu.zzs(obj, j); } return zziu.zzt(obj, j); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, boolean z) { if (zziu.zzabr) { zziu.zzb(obj, j, z); } else { zziu.zzc(obj, j, z); } } @Override // com.google.android.gms.internal.vision.zziu.zzd public final float zzn(Object obj, long j) { return Float.intBitsToFloat(zzk(obj, j)); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, float f) { zzb(obj, j, Float.floatToIntBits(f)); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final double zzo(Object obj, long j) { return Double.longBitsToDouble(zzl(obj, j)); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(Object obj, long j, double d) { zza(obj, j, Double.doubleToLongBits(d)); } @Override // com.google.android.gms.internal.vision.zziu.zzd public final void zza(byte[] bArr, long j, long j2, long j3) { Memory.pokeByteArray((int) j2, bArr, (int) j, (int) j3); } } /* JADX INFO: Access modifiers changed from: package-private */ public static T zzh(Class cls) { try { return (T) zzzc.allocateInstance(cls); } catch (InstantiationException e) { throw new IllegalStateException(e); } } private static int zzi(Class cls) { if (zzsr) { return zzabb.zzabs.arrayBaseOffset(cls); } return -1; } private static int zzj(Class cls) { if (zzsr) { return zzabb.zzabs.arrayIndexScale(cls); } return -1; } /* JADX INFO: Access modifiers changed from: package-private */ public static int zzk(Object obj, long j) { return zzabb.zzk(obj, j); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zzb(Object obj, long j, int i) { zzabb.zzb(obj, j, i); } /* JADX INFO: Access modifiers changed from: package-private */ public static long zzl(Object obj, long j) { return zzabb.zzl(obj, j); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(Object obj, long j, long j2) { zzabb.zza(obj, j, j2); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean zzm(Object obj, long j) { return zzabb.zzm(obj, j); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(Object obj, long j, boolean z) { zzabb.zza(obj, j, z); } /* JADX INFO: Access modifiers changed from: package-private */ public static float zzn(Object obj, long j) { return zzabb.zzn(obj, j); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(Object obj, long j, float f) { zzabb.zza(obj, j, f); } /* JADX INFO: Access modifiers changed from: package-private */ public static double zzo(Object obj, long j) { return zzabb.zzo(obj, j); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(Object obj, long j, double d) { zzabb.zza(obj, j, d); } /* JADX INFO: Access modifiers changed from: package-private */ public static Object zzp(Object obj, long j) { return zzabb.zzabs.getObject(obj, j); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(Object obj, long j, Object obj2) { zzabb.zzabs.putObject(obj, j, obj2); } /* JADX INFO: Access modifiers changed from: package-private */ public static byte zza(byte[] bArr, long j) { return zzabb.zzy(bArr, zzabd + j); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(byte[] bArr, long j, byte b) { zzabb.zze(bArr, zzabd + j, b); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(byte[] bArr, long j, long j2, long j3) { zzabb.zza(bArr, j, j2, j3); } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(long j, byte b) { zzabb.zza(j, b); } /* JADX INFO: Access modifiers changed from: package-private */ public static long zzb(ByteBuffer byteBuffer) { return zzabb.zzl(byteBuffer, zzabq); } /* JADX INFO: Access modifiers changed from: package-private */ public static Unsafe zzhj() { try { return (Unsafe) AccessController.doPrivileged(new zziv()); } catch (Throwable unused) { return null; } } private static boolean zzhk() { Unsafe unsafe = zzzc; if (unsafe == null) { return false; } try { Class cls = unsafe.getClass(); cls.getMethod("objectFieldOffset", Field.class); cls.getMethod("arrayBaseOffset", Class.class); cls.getMethod("arrayIndexScale", Class.class); cls.getMethod("getInt", Object.class, Long.TYPE); cls.getMethod("putInt", Object.class, Long.TYPE, Integer.TYPE); cls.getMethod("getLong", Object.class, Long.TYPE); cls.getMethod("putLong", Object.class, Long.TYPE, Long.TYPE); cls.getMethod("getObject", Object.class, Long.TYPE); cls.getMethod("putObject", Object.class, Long.TYPE, Object.class); if (zzeg.zzck()) { return true; } cls.getMethod("getByte", Object.class, Long.TYPE); cls.getMethod("putByte", Object.class, Long.TYPE, Byte.TYPE); cls.getMethod("getBoolean", Object.class, Long.TYPE); cls.getMethod("putBoolean", Object.class, Long.TYPE, Boolean.TYPE); cls.getMethod("getFloat", Object.class, Long.TYPE); cls.getMethod("putFloat", Object.class, Long.TYPE, Float.TYPE); cls.getMethod("getDouble", Object.class, Long.TYPE); cls.getMethod("putDouble", Object.class, Long.TYPE, Double.TYPE); return true; } catch (Throwable th) { Logger logger2 = logger; Level level = Level.WARNING; String valueOf = String.valueOf(th); StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 71); sb.append("platform method missing - proto runtime falling back to safer methods: "); sb.append(valueOf); logger2.logp(level, "o.vqr", "supportsUnsafeArrayOperations", sb.toString()); return false; } } private static boolean zzhl() { Unsafe unsafe = zzzc; if (unsafe == null) { return false; } try { Class cls = unsafe.getClass(); cls.getMethod("objectFieldOffset", Field.class); cls.getMethod("getLong", Object.class, Long.TYPE); if (zzhm() == null) { return false; } if (zzeg.zzck()) { return true; } cls.getMethod("getByte", Long.TYPE); cls.getMethod("putByte", Long.TYPE, Byte.TYPE); cls.getMethod("getInt", Long.TYPE); cls.getMethod("putInt", Long.TYPE, Integer.TYPE); cls.getMethod("getLong", Long.TYPE); cls.getMethod("putLong", Long.TYPE, Long.TYPE); cls.getMethod("copyMemory", Long.TYPE, Long.TYPE, Long.TYPE); cls.getMethod("copyMemory", Object.class, Long.TYPE, Object.class, Long.TYPE, Long.TYPE); return true; } catch (Throwable th) { Logger logger2 = logger; Level level = Level.WARNING; String valueOf = String.valueOf(th); StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 71); sb.append("platform method missing - proto runtime falling back to safer methods: "); sb.append(valueOf); logger2.logp(level, "o.vqr", "supportsUnsafeByteBufferOperations", sb.toString()); return false; } } private static boolean zzk(Class cls) { if (!zzeg.zzck()) { return false; } try { Class cls2 = zzrm; cls2.getMethod("peekLong", cls, Boolean.TYPE); cls2.getMethod("pokeLong", cls, Long.TYPE, Boolean.TYPE); cls2.getMethod("pokeInt", cls, Integer.TYPE, Boolean.TYPE); cls2.getMethod("peekInt", cls, Boolean.TYPE); cls2.getMethod("pokeByte", cls, Byte.TYPE); cls2.getMethod("peekByte", cls); cls2.getMethod("pokeByteArray", cls, byte[].class, Integer.TYPE, Integer.TYPE); cls2.getMethod("peekByteArray", cls, byte[].class, Integer.TYPE, Integer.TYPE); return true; } catch (Throwable unused) { return false; } } private static Field zzhm() { Field zzb2; if (zzeg.zzck() && (zzb2 = zzb(Buffer.class, "effectiveDirectAddress")) != null) { return zzb2; } Field zzb3 = zzb(Buffer.class, PlaceTypes.ADDRESS); if (zzb3 == null || zzb3.getType() != Long.TYPE) { return null; } return zzb3; } private static Field zzb(Class cls, String str) { try { Field declaredField = cls.getDeclaredField(str); declaredField.setAccessible(true); return declaredField; } catch (Throwable unused) { return null; } } /* JADX INFO: Access modifiers changed from: private */ public static byte zzq(Object obj, long j) { return (byte) (zzk(obj, (-4) & j) >>> ((int) (((~j) & 3) << 3))); } /* JADX INFO: Access modifiers changed from: private */ public static byte zzr(Object obj, long j) { return (byte) (zzk(obj, (-4) & j) >>> ((int) ((j & 3) << 3))); } /* JADX INFO: Access modifiers changed from: private */ public static void zza(Object obj, long j, byte b) { long j2 = (-4) & j; int zzk = zzk(obj, j2); int i = ((~((int) j)) & 3) << 3; zzb(obj, j2, ((~(255 << i)) & zzk) | ((b & UnsignedBytes.MAX_VALUE) << i)); } /* JADX INFO: Access modifiers changed from: private */ public static void zzb(Object obj, long j, byte b) { long j2 = (-4) & j; int zzk = zzk(obj, j2); int i = (((int) j) & 3) << 3; zzb(obj, j2, ((~(255 << i)) & zzk) | ((b & UnsignedBytes.MAX_VALUE) << i)); } /* JADX INFO: Access modifiers changed from: private */ public static boolean zzs(Object obj, long j) { return zzq(obj, j) != 0; } /* JADX INFO: Access modifiers changed from: private */ public static boolean zzt(Object obj, long j) { return zzr(obj, j) != 0; } /* JADX INFO: Access modifiers changed from: private */ public static void zzb(Object obj, long j, boolean z) { zza(obj, j, z ? (byte) 1 : (byte) 0); } /* JADX INFO: Access modifiers changed from: private */ public static void zzc(Object obj, long j, boolean z) { zzb(obj, j, z ? (byte) 1 : (byte) 0); } /* JADX WARN: Removed duplicated region for block: B:13:0x00dd */ /* JADX WARN: Removed duplicated region for block: B:17:0x00df */ static { /* java.lang.Class r0 = com.google.android.gms.internal.vision.zziu.class java.lang.String r0 = r0.getName() java.util.logging.Logger r0 = java.util.logging.Logger.getLogger(r0) com.google.android.gms.internal.vision.zziu.logger = r0 sun.misc.Unsafe r0 = zzhj() com.google.android.gms.internal.vision.zziu.zzzc = r0 java.lang.Class r1 = com.google.android.gms.internal.vision.zzeg.zzcl() com.google.android.gms.internal.vision.zziu.zzrm = r1 java.lang.Class r1 = java.lang.Long.TYPE boolean r1 = zzk(r1) com.google.android.gms.internal.vision.zziu.zzaaz = r1 java.lang.Class r2 = java.lang.Integer.TYPE boolean r2 = zzk(r2) com.google.android.gms.internal.vision.zziu.zzaba = r2 if (r0 != 0) goto L2b goto L41 L2b: boolean r3 = com.google.android.gms.internal.vision.zzeg.zzck() if (r3 == 0) goto L43 if (r1 == 0) goto L39 com.google.android.gms.internal.vision.zziu$zzb r1 = new com.google.android.gms.internal.vision.zziu$zzb r1.(r0) goto L48 L39: if (r2 == 0) goto L41 com.google.android.gms.internal.vision.zziu$zza r1 = new com.google.android.gms.internal.vision.zziu$zza r1.(r0) goto L48 L41: r1 = 0 goto L48 L43: com.google.android.gms.internal.vision.zziu$zzc r1 = new com.google.android.gms.internal.vision.zziu$zzc r1.(r0) L48: com.google.android.gms.internal.vision.zziu.zzabb = r1 boolean r0 = zzhl() com.google.android.gms.internal.vision.zziu.zzabc = r0 boolean r0 = zzhk() com.google.android.gms.internal.vision.zziu.zzsr = r0 java.lang.Class r0 = byte[].class int r0 = zzi(r0) long r2 = (long) r0 com.google.android.gms.internal.vision.zziu.zzabd = r2 java.lang.Class r0 = boolean[].class int r2 = zzi(r0) long r2 = (long) r2 com.google.android.gms.internal.vision.zziu.zzabe = r2 int r0 = zzj(r0) long r2 = (long) r0 com.google.android.gms.internal.vision.zziu.zzabf = r2 java.lang.Class r0 = int[].class int r2 = zzi(r0) long r2 = (long) r2 com.google.android.gms.internal.vision.zziu.zzabg = r2 int r0 = zzj(r0) long r2 = (long) r0 com.google.android.gms.internal.vision.zziu.zzabh = r2 java.lang.Class r0 = long[].class int r2 = zzi(r0) long r2 = (long) r2 com.google.android.gms.internal.vision.zziu.zzabi = r2 int r0 = zzj(r0) long r2 = (long) r0 com.google.android.gms.internal.vision.zziu.zzabj = r2 java.lang.Class r0 = float[].class int r2 = zzi(r0) long r2 = (long) r2 com.google.android.gms.internal.vision.zziu.zzabk = r2 int r0 = zzj(r0) long r2 = (long) r0 com.google.android.gms.internal.vision.zziu.zzabl = r2 java.lang.Class r0 = double[].class int r2 = zzi(r0) long r2 = (long) r2 com.google.android.gms.internal.vision.zziu.zzabm = r2 int r0 = zzj(r0) long r2 = (long) r0 com.google.android.gms.internal.vision.zziu.zzabn = r2 java.lang.Class r0 = java.lang.Object[].class int r0 = zzi(r0) long r2 = (long) r0 com.google.android.gms.internal.vision.zziu.zzabo = r2 java.lang.Class r0 = java.lang.Object[].class int r0 = zzj(r0) long r2 = (long) r0 com.google.android.gms.internal.vision.zziu.zzabp = r2 java.lang.reflect.Field r0 = zzhm() if (r0 == 0) goto Ld1 if (r1 != 0) goto Lca goto Ld1 Lca: sun.misc.Unsafe r1 = r1.zzabs long r0 = r1.objectFieldOffset(r0) goto Ld3 Ld1: r0 = -1 Ld3: com.google.android.gms.internal.vision.zziu.zzabq = r0 java.nio.ByteOrder r0 = java.nio.ByteOrder.nativeOrder() java.nio.ByteOrder r1 = java.nio.ByteOrder.BIG_ENDIAN if (r0 != r1) goto Ldf r0 = 1 goto Le0 Ldf: r0 = 0 Le0: com.google.android.gms.internal.vision.zziu.zzabr = r0 return */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.vision.zziu.():void"); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean zzhi() { return zzabc; } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean zzhh() { return zzsr; } }