package androidx.work.impl.background.systemalarm;

import a6.i;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import androidx.work.impl.background.systemalarm.ConstraintProxy;
import z5.k;

/* loaded from: classes.dex */
public class ConstraintProxyUpdateReceiver extends BroadcastReceiver {

    /* renamed from: a, reason: collision with root package name */
    static final String f5919a = k.f("ConstrntProxyUpdtRecvr");

    /* loaded from: classes.dex */
    class a implements Runnable {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ Intent f5920p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ Context f5921q;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ BroadcastReceiver.PendingResult f5922r;

        a(Intent intent, Context context, BroadcastReceiver.PendingResult pendingResult) {
            this.f5920p = intent;
            this.f5921q = context;
            this.f5922r = pendingResult;
        }

        @Override // java.lang.Runnable
        public void run() {
            try {
                boolean booleanExtra = this.f5920p.getBooleanExtra("KEY_BATTERY_NOT_LOW_PROXY_ENABLED", false);
                boolean booleanExtra2 = this.f5920p.getBooleanExtra("KEY_BATTERY_CHARGING_PROXY_ENABLED", false);
                boolean booleanExtra3 = this.f5920p.getBooleanExtra("KEY_STORAGE_NOT_LOW_PROXY_ENABLED", false);
                boolean booleanExtra4 = this.f5920p.getBooleanExtra("KEY_NETWORK_STATE_PROXY_ENABLED", false);
                k.c().a(ConstraintProxyUpdateReceiver.f5919a, String.format("Updating proxies: BatteryNotLowProxy enabled (%s), BatteryChargingProxy enabled (%s), StorageNotLowProxy (%s), NetworkStateProxy enabled (%s)", Boolean.valueOf(booleanExtra), Boolean.valueOf(booleanExtra2), Boolean.valueOf(booleanExtra3), Boolean.valueOf(booleanExtra4)), new Throwable[0]);
                i6.d.a(this.f5921q, ConstraintProxy.BatteryNotLowProxy.class, booleanExtra);
                i6.d.a(this.f5921q, ConstraintProxy.BatteryChargingProxy.class, booleanExtra2);
                i6.d.a(this.f5921q, ConstraintProxy.StorageNotLowProxy.class, booleanExtra3);
                i6.d.a(this.f5921q, ConstraintProxy.NetworkStateProxy.class, booleanExtra4);
            } finally {
                this.f5922r.finish();
            }
        }
    }

    public static Intent a(Context context, boolean z10, boolean z11, boolean z12, boolean z13) {
        Intent intent = new Intent("androidx.work.impl.background.systemalarm.UpdateProxies");
        intent.setComponent(new ComponentName(context, (Class<?>) ConstraintProxyUpdateReceiver.class));
        intent.putExtra("KEY_BATTERY_NOT_LOW_PROXY_ENABLED", z10).putExtra("KEY_BATTERY_CHARGING_PROXY_ENABLED", z11).putExtra("KEY_STORAGE_NOT_LOW_PROXY_ENABLED", z12).putExtra("KEY_NETWORK_STATE_PROXY_ENABLED", z13);
        return intent;
    }

    @Override // android.content.BroadcastReceiver
    public void onReceive(Context context, Intent intent) {
        String action = intent != null ? intent.getAction() : null;
        if ("androidx.work.impl.background.systemalarm.UpdateProxies".equals(action)) {
            i.o(context).u().b(new a(intent, context, goAsync()));
        } else {
            k.c().a(f5919a, String.format("Ignoring unknown action %s", action), new Throwable[0]);
        }
    }
}
