package com.google.android.gms.internal.measurement;

import java.lang.reflect.Field;
import java.nio.Buffer;
import java.util.logging.Level;
import java.util.logging.Logger;
import sun.misc.Unsafe;

/* JADX INFO: loaded from: classes2.dex */
public abstract class i7 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Unsafe f20237a;

    public final void a(int i10, long j10, Object obj) {
        this.f20237a.putInt(obj, j10, i10);
    }

    public final void b(Object obj, long j10, long j11) {
        this.f20237a.putLong(obj, j10, j11);
    }

    public final boolean c() {
        Unsafe unsafe = this.f20237a;
        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);
            Class<?> cls2 = Long.TYPE;
            cls.getMethod("getInt", Object.class, cls2);
            cls.getMethod("putInt", Object.class, cls2, Integer.TYPE);
            cls.getMethod("getLong", Object.class, cls2);
            cls.getMethod("putLong", Object.class, cls2, cls2);
            cls.getMethod("getObject", Object.class, cls2);
            cls.getMethod("putObject", Object.class, cls2, Object.class);
            return true;
        } catch (Throwable th) {
            Unsafe unsafe2 = j7.f20259a;
            Logger.getLogger(j7.class.getName()).logp(Level.WARNING, "com.google.protobuf.UnsafeUtil", "logMissingMethod", "platform method missing - proto runtime falling back to safer methods: ".concat(String.valueOf(th)));
            return false;
        }
    }

    public final boolean d() {
        Field declaredField;
        Field declaredField2;
        Unsafe unsafe = this.f20237a;
        if (unsafe == null) {
            return false;
        }
        try {
            Class<?> cls = unsafe.getClass();
            cls.getMethod("objectFieldOffset", Field.class);
            cls.getMethod("getLong", Object.class, Long.TYPE);
            Unsafe unsafe2 = j7.f20259a;
            Field field = null;
            try {
                declaredField = Buffer.class.getDeclaredField("effectiveDirectAddress");
            } catch (Throwable unused) {
                declaredField = null;
            }
            if (declaredField != null) {
                field = declaredField;
            } else {
                try {
                    declaredField2 = Buffer.class.getDeclaredField("address");
                } catch (Throwable unused2) {
                    declaredField2 = null;
                }
                if (declaredField2 != null) {
                    if (declaredField2.getType() == Long.TYPE) {
                        field = declaredField2;
                    }
                }
            }
            return field != null;
        } catch (Throwable th) {
            Unsafe unsafe3 = j7.f20259a;
            Logger.getLogger(j7.class.getName()).logp(Level.WARNING, "com.google.protobuf.UnsafeUtil", "logMissingMethod", "platform method missing - proto runtime falling back to safer methods: ".concat(String.valueOf(th)));
            return false;
        }
    }

    public final int e(long j10, Object obj) {
        return this.f20237a.getInt(obj, j10);
    }

    public final long f(long j10, Object obj) {
        return this.f20237a.getLong(obj, j10);
    }
}
