package com.google.android.gms.measurement;

import P.g;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.util.SparseArray;
import d3.C0817r0;
import d3.Z;
import p0.AbstractC1410a;

/* JADX INFO: loaded from: classes.dex */
public final class AppMeasurementReceiver extends AbstractC1410a {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public g f10091c;

    @Override // android.content.BroadcastReceiver
    public final void onReceive(Context context, Intent intent) {
        if (this.f10091c == null) {
            this.f10091c = new g(28, this);
        }
        g gVar = this.f10091c;
        gVar.getClass();
        Z z8 = C0817r0.q(context, null, null).f12150y;
        C0817r0.k(z8);
        if (intent == null) {
            z8.f11878y.b("Receiver called with null intent");
            return;
        }
        String action = intent.getAction();
        z8.D.c(action, "Local receiver got");
        if (!"com.google.android.gms.measurement.UPLOAD".equals(action)) {
            if ("com.android.vending.INSTALL_REFERRER".equals(action)) {
                z8.f11878y.b("Install Referrer Broadcasts are deprecated");
                return;
            }
            return;
        }
        Intent className = new Intent().setClassName(context, "com.google.android.gms.measurement.AppMeasurementService");
        className.setAction("com.google.android.gms.measurement.UPLOAD");
        z8.D.b("Starting wakeful intent.");
        ((AppMeasurementReceiver) gVar.f5246r).getClass();
        SparseArray sparseArray = AbstractC1410a.f16022a;
        synchronized (sparseArray) {
            try {
                int i = AbstractC1410a.f16023b;
                int i5 = i + 1;
                AbstractC1410a.f16023b = i5;
                if (i5 <= 0) {
                    AbstractC1410a.f16023b = 1;
                }
                className.putExtra("androidx.contentpager.content.wakelockid", i);
                ComponentName componentNameStartService = context.startService(className);
                if (componentNameStartService == null) {
                    return;
                }
                PowerManager.WakeLock wakeLockNewWakeLock = ((PowerManager) context.getSystemService("power")).newWakeLock(1, "androidx.core:wake:" + componentNameStartService.flattenToShortString());
                wakeLockNewWakeLock.setReferenceCounted(false);
                wakeLockNewWakeLock.acquire(60000L);
                sparseArray.put(i, wakeLockNewWakeLock);
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
