jimu-decompiled/sources/com/google/firebase/iid/zzr.java
2025-05-13 19:24:51 +02:00

147 lines
5.5 KiB
Java

package com.google.firebase.iid;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import com.baidu.cloud.media.player.BDCloudMediaPlayer;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.FirebaseApp;
import com.tencent.open.SocialConstants;
import java.io.IOException;
import java.util.concurrent.Executor;
/* loaded from: classes.dex */
final class zzr implements MessagingChannel {
private final FirebaseApp a;
private final zzan b;
private final zzat c;
private final Executor d;
zzr(FirebaseApp firebaseApp, zzan zzanVar, Executor executor) {
this(firebaseApp, zzanVar, executor, new zzat(firebaseApp.a(), zzanVar));
}
@Override // com.google.firebase.iid.MessagingChannel
public final Task<Void> a(String str, String str2) {
return Tasks.a((Object) null);
}
@Override // com.google.firebase.iid.MessagingChannel
public final boolean a() {
return true;
}
@Override // com.google.firebase.iid.MessagingChannel
public final boolean b() {
return this.b.a() != 0;
}
private zzr(FirebaseApp firebaseApp, zzan zzanVar, Executor executor, zzat zzatVar) {
this.a = firebaseApp;
this.b = zzanVar;
this.c = zzatVar;
this.d = executor;
}
@Override // com.google.firebase.iid.MessagingChannel
public final Task<String> a(String str, String str2, String str3, String str4) {
return b(a(str, str3, str4, new Bundle()));
}
@Override // com.google.firebase.iid.MessagingChannel
public final Task<Void> b(String str, String str2, String str3) {
Bundle bundle = new Bundle();
String valueOf = String.valueOf(str3);
bundle.putString("gcm.topic", valueOf.length() != 0 ? "/topics/".concat(valueOf) : new String("/topics/"));
String valueOf2 = String.valueOf(str3);
return a(b(a(str, str2, valueOf2.length() != 0 ? "/topics/".concat(valueOf2) : new String("/topics/"), bundle)));
}
@Override // com.google.firebase.iid.MessagingChannel
public final Task<Void> a(String str, String str2, String str3) {
Bundle bundle = new Bundle();
String valueOf = String.valueOf(str3);
bundle.putString("gcm.topic", valueOf.length() != 0 ? "/topics/".concat(valueOf) : new String("/topics/"));
bundle.putString("delete", "1");
String valueOf2 = String.valueOf(str3);
return a(b(a(str, str2, valueOf2.length() != 0 ? "/topics/".concat(valueOf2) : new String("/topics/"), bundle)));
}
private final Task<String> b(Task<Bundle> task) {
return task.a(this.d, new zzu(this));
}
private final Task<Bundle> a(String str, String str2, String str3, final Bundle bundle) {
bundle.putString("scope", str3);
bundle.putString("sender", str2);
bundle.putString("subtype", str2);
bundle.putString(SocialConstants.PARAM_APP_ID, str);
bundle.putString("gmp_app_id", this.a.c().a());
bundle.putString("gmsv", Integer.toString(this.b.d()));
bundle.putString("osv", Integer.toString(Build.VERSION.SDK_INT));
bundle.putString("app_ver", this.b.b());
bundle.putString("app_ver_name", this.b.c());
bundle.putString("cliv", "fiid-12451000");
final TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
this.d.execute(new Runnable(this, bundle, taskCompletionSource) { // from class: com.google.firebase.iid.zzs
private final zzr a;
private final Bundle b;
private final TaskCompletionSource c;
{
this.a = this;
this.b = bundle;
this.c = taskCompletionSource;
}
@Override // java.lang.Runnable
public final void run() {
this.a.a(this.b, this.c);
}
});
return taskCompletionSource.a();
}
/* JADX INFO: Access modifiers changed from: private */
public static String a(Bundle bundle) throws IOException {
if (bundle != null) {
String string = bundle.getString("registration_id");
if (string != null) {
return string;
}
String string2 = bundle.getString("unregistered");
if (string2 != null) {
return string2;
}
String string3 = bundle.getString(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR);
if ("RST".equals(string3)) {
throw new IOException("INSTANCE_ID_RESET");
}
if (string3 != null) {
throw new IOException(string3);
}
String valueOf = String.valueOf(bundle);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 21);
sb.append("Unexpected response: ");
sb.append(valueOf);
Log.w("FirebaseInstanceId", sb.toString(), new Throwable());
throw new IOException("SERVICE_NOT_AVAILABLE");
}
throw new IOException("SERVICE_NOT_AVAILABLE");
}
private final <T> Task<Void> a(Task<T> task) {
return task.a(zzi.a(), new zzt(this));
}
final /* synthetic */ void a(Bundle bundle, TaskCompletionSource taskCompletionSource) {
try {
taskCompletionSource.a((TaskCompletionSource) this.c.a(bundle));
} catch (IOException e) {
taskCompletionSource.a((Exception) e);
}
}
}