103 lines
3.3 KiB
Java
103 lines
3.3 KiB
Java
package com.google.firebase.iid;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.NetworkInfo;
|
|
import android.os.PowerManager;
|
|
import android.util.Log;
|
|
import java.io.IOException;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class zzay implements Runnable {
|
|
private final long a;
|
|
private final PowerManager.WakeLock b = ((PowerManager) a().getSystemService("power")).newWakeLock(1, "fiid-sync");
|
|
private final FirebaseInstanceId c;
|
|
private final zzan d;
|
|
private final zzba e;
|
|
|
|
zzay(FirebaseInstanceId firebaseInstanceId, zzan zzanVar, zzba zzbaVar, long j) {
|
|
this.c = firebaseInstanceId;
|
|
this.d = zzanVar;
|
|
this.e = zzbaVar;
|
|
this.a = j;
|
|
this.b.setReferenceCounted(false);
|
|
}
|
|
|
|
private final boolean c() {
|
|
try {
|
|
if (this.c.g()) {
|
|
return true;
|
|
}
|
|
this.c.h();
|
|
return true;
|
|
} catch (IOException e) {
|
|
String valueOf = String.valueOf(e.getMessage());
|
|
Log.e("FirebaseInstanceId", valueOf.length() != 0 ? "Build channel failed: ".concat(valueOf) : new String("Build channel failed: "));
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private final boolean d() {
|
|
zzax c = this.c.c();
|
|
if (c != null && !c.a(this.d.b())) {
|
|
return true;
|
|
}
|
|
try {
|
|
String d = this.c.d();
|
|
if (d == null) {
|
|
Log.e("FirebaseInstanceId", "Token retrieval failed: null");
|
|
return false;
|
|
}
|
|
if (Log.isLoggable("FirebaseInstanceId", 3)) {
|
|
Log.d("FirebaseInstanceId", "Token successfully retrieved");
|
|
}
|
|
if (c == null || (c != null && !d.equals(c.a))) {
|
|
Context a = a();
|
|
Intent intent = new Intent("com.google.firebase.messaging.NEW_TOKEN");
|
|
intent.putExtra("token", d);
|
|
zzav.b(a, intent);
|
|
zzav.a(a, new Intent("com.google.firebase.iid.TOKEN_REFRESH"));
|
|
}
|
|
return true;
|
|
} catch (IOException | SecurityException e) {
|
|
String valueOf = String.valueOf(e.getMessage());
|
|
Log.e("FirebaseInstanceId", valueOf.length() != 0 ? "Token retrieval failed: ".concat(valueOf) : new String("Token retrieval failed: "));
|
|
return false;
|
|
}
|
|
}
|
|
|
|
final Context a() {
|
|
return this.c.b().a();
|
|
}
|
|
|
|
final boolean b() {
|
|
ConnectivityManager connectivityManager = (ConnectivityManager) a().getSystemService("connectivity");
|
|
NetworkInfo activeNetworkInfo = connectivityManager != null ? connectivityManager.getActiveNetworkInfo() : null;
|
|
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
this.b.acquire();
|
|
try {
|
|
this.c.a(true);
|
|
if (!this.c.f()) {
|
|
this.c.a(false);
|
|
return;
|
|
}
|
|
if (!b()) {
|
|
new zzaz(this).a();
|
|
return;
|
|
}
|
|
if (c() && d() && this.e.a(this.c)) {
|
|
this.c.a(false);
|
|
} else {
|
|
this.c.a(this.a);
|
|
}
|
|
} finally {
|
|
this.b.release();
|
|
}
|
|
}
|
|
}
|