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

import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.Context;
import android.os.UserHandle;
import androidx.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* JADX INFO: loaded from: classes2.dex */
public final class q0 {

    @Nullable
    private static final Method zza = zzc();

    @Nullable
    private static final Method zzb = zzb();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final JobScheduler f20371a;

    public q0(JobScheduler jobScheduler) {
        this.f20371a = jobScheduler;
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0037  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void a(Context context, JobInfo jobInfo) {
        Integer num;
        int iIntValue;
        JobScheduler jobScheduler = (JobScheduler) context.getSystemService("jobscheduler");
        jobScheduler.getClass();
        if (zza == null || context.checkSelfPermission("android.permission.UPDATE_DEVICE_STATS") != 0) {
            jobScheduler.schedule(jobInfo);
            return;
        }
        q0 q0Var = new q0(jobScheduler);
        Method method = zzb;
        if (method != null) {
            try {
                num = (Integer) method.invoke(UserHandle.class, new Object[0]);
            } catch (IllegalAccessException | InvocationTargetException unused) {
            }
            iIntValue = num != null ? num.intValue() : 0;
        }
        Method method2 = zza;
        JobScheduler jobScheduler2 = q0Var.f20371a;
        if (method2 != null) {
            try {
                Integer num2 = (Integer) method2.invoke(jobScheduler2, jobInfo, "com.google.android.gms", Integer.valueOf(iIntValue), "UploadAlarm");
                if (num2 != null) {
                    num2.intValue();
                    return;
                }
                return;
            } catch (IllegalAccessException | InvocationTargetException unused2) {
            }
        }
        jobScheduler2.schedule(jobInfo);
    }

    @Nullable
    private static Method zzb() {
        try {
            return UserHandle.class.getDeclaredMethod("myUserId", new Class[0]);
        } catch (NoSuchMethodException unused) {
            return null;
        }
    }

    @Nullable
    private static Method zzc() {
        try {
            return JobScheduler.class.getDeclaredMethod("scheduleAsPackage", JobInfo.class, String.class, Integer.TYPE, String.class);
        } catch (NoSuchMethodException unused) {
            return null;
        }
    }
}
