package com.google.firebase.messaging; import android.content.Context; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.PowerManager; import android.util.Log; import com.google.firebase.iid.zzao; import java.io.IOException; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class zzad implements Runnable { private static final Object zzf = new Object(); private static Boolean zzg; private static Boolean zzh; private final Context zza; private final zzao zzb; private final PowerManager.WakeLock zzc; private final zzab zzd; private final long zze; /* JADX INFO: Access modifiers changed from: package-private */ public zzad(zzab zzabVar, Context context, zzao zzaoVar, long j) { this.zzd = zzabVar; this.zza = context; this.zze = j; this.zzb = zzaoVar; this.zzc = ((PowerManager) context.getSystemService("power")).newWakeLock(1, "wake:com.google.firebase.messaging"); } @Override // java.lang.Runnable public final void run() { if (zza(this.zza)) { this.zzc.acquire(zzd.zza); } try { try { this.zzd.zza(true); if (!this.zzb.zza()) { this.zzd.zza(false); if (zza(this.zza)) { try { this.zzc.release(); return; } catch (RuntimeException unused) { return; } } return; } if (zzb(this.zza) && !zzb()) { zzac zzacVar = new zzac(this, this); zzacVar.zza.zza.registerReceiver(zzacVar, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE")); if (zza(this.zza)) { try { this.zzc.release(); return; } catch (RuntimeException unused2) { return; } } return; } if (this.zzd.zzb()) { this.zzd.zza(false); } else { this.zzd.zza(this.zze); } if (zza(this.zza)) { try { this.zzc.release(); } catch (RuntimeException unused3) { } } } catch (Throwable th) { if (zza(this.zza)) { try { this.zzc.release(); } catch (RuntimeException unused4) { } } throw th; } } catch (IOException e) { e.getMessage(); this.zzd.zza(false); if (zza(this.zza)) { try { this.zzc.release(); } catch (RuntimeException unused5) { } } } } /* JADX INFO: Access modifiers changed from: private */ public final boolean zzb() { synchronized (this) { ConnectivityManager connectivityManager = (ConnectivityManager) this.zza.getSystemService("connectivity"); NetworkInfo activeNetworkInfo = connectivityManager != null ? connectivityManager.getActiveNetworkInfo() : null; if (activeNetworkInfo != null) { if (activeNetworkInfo.isConnected()) { return true; } } return false; } } /* JADX INFO: Access modifiers changed from: private */ public static boolean zzc() { return Log.isLoggable("FirebaseMessaging", 3); } private static boolean zza(Context context) { boolean booleanValue; boolean booleanValue2; synchronized (zzf) { Boolean bool = zzg; if (bool == null) { booleanValue = zza(context, "android.permission.WAKE_LOCK", bool); } else { booleanValue = bool.booleanValue(); } Boolean valueOf = Boolean.valueOf(booleanValue); zzg = valueOf; booleanValue2 = valueOf.booleanValue(); } return booleanValue2; } private static boolean zzb(Context context) { boolean booleanValue; boolean booleanValue2; synchronized (zzf) { Boolean bool = zzh; if (bool == null) { booleanValue = zza(context, "android.permission.ACCESS_NETWORK_STATE", bool); } else { booleanValue = bool.booleanValue(); } Boolean valueOf = Boolean.valueOf(booleanValue); zzh = valueOf; booleanValue2 = valueOf.booleanValue(); } return booleanValue2; } private static boolean zza(Context context, String str, Boolean bool) { if (bool != null) { return bool.booleanValue(); } return context.checkCallingOrSelfPermission(str) == 0; } }