package com.google.android.gms.internal.gtm; import android.content.Context; import android.content.IntentFilter; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class zzfo extends zzfn { private static final Object zzakn = new Object(); private static zzfo zzapl; private Context zzako; private zzem zzapg; private volatile zzej zzaph; private zzfr zzapj; private zzex zzapk; private int zzakr = 1800000; private boolean zzaks = true; private boolean zzakt = false; private boolean zzapi = false; private boolean connected = true; private boolean zzaku = true; private zzen zzaol = new zzfp(this); private boolean zzakx = false; public static zzfo zzkv() { if (zzapl == null) { zzapl = new zzfo(); } return zzapl; } private zzfo() { } /* JADX INFO: Access modifiers changed from: package-private */ public final void zza(Context context, zzej zzejVar) { synchronized (this) { if (this.zzako != null) { return; } this.zzako = context.getApplicationContext(); if (this.zzaph == null) { this.zzaph = zzejVar; } } } /* JADX INFO: Access modifiers changed from: package-private */ public final zzem zzkw() { zzem zzemVar; synchronized (this) { if (this.zzapg == null) { if (this.zzako == null) { throw new IllegalStateException("Cant get a store unless we have a context"); } this.zzapg = new zzey(this.zzaol, this.zzako); } if (this.zzapj == null) { zzfs zzfsVar = new zzfs(this, null); this.zzapj = zzfsVar; int i = this.zzakr; if (i > 0) { zzfsVar.zzh(i); } } this.zzakt = true; if (this.zzaks) { dispatch(); this.zzaks = false; } if (this.zzapk == null && this.zzaku) { zzex zzexVar = new zzex(this); this.zzapk = zzexVar; Context context = this.zzako; IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE"); context.registerReceiver(zzexVar, intentFilter); IntentFilter intentFilter2 = new IntentFilter(); intentFilter2.addAction("com.google.analytics.RADIO_POWERED"); intentFilter2.addCategory(context.getPackageName()); context.registerReceiver(zzexVar, intentFilter2); } zzemVar = this.zzapg; } return zzemVar; } public final void dispatch() { synchronized (this) { if (!this.zzakt) { zzev.zzab("Dispatch call queued. Dispatch will run once initialization is complete."); this.zzaks = true; } else { if (!this.zzapi) { this.zzapi = true; this.zzaph.zzc(new zzfq(this)); } } } } /* JADX INFO: Access modifiers changed from: package-private */ public final void zza(boolean z, boolean z2) { synchronized (this) { boolean isPowerSaveMode = isPowerSaveMode(); this.zzakx = z; this.connected = z2; if (isPowerSaveMode() == isPowerSaveMode) { return; } if (isPowerSaveMode()) { this.zzapj.cancel(); zzev.zzab("PowerSaveMode initiated."); } else { this.zzapj.zzh(this.zzakr); zzev.zzab("PowerSaveMode terminated."); } } } @Override // com.google.android.gms.internal.gtm.zzfn public final void zzf(boolean z) { synchronized (this) { zza(this.zzakx, z); } } @Override // com.google.android.gms.internal.gtm.zzfn public final void zzjp() { synchronized (this) { if (!isPowerSaveMode()) { this.zzapj.zzjt(); } } } /* JADX INFO: Access modifiers changed from: package-private */ public static /* synthetic */ boolean zza(zzfo zzfoVar, boolean z) { zzfoVar.zzapi = false; return false; } /* JADX INFO: Access modifiers changed from: private */ public final boolean isPowerSaveMode() { return this.zzakx || !this.connected || this.zzakr <= 0; } }