package com.google.firebase.iid; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.os.Parcelable; import android.util.Log; import androidx.collection.SimpleArrayMap; 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.iid.zzl; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.regex.Matcher; import java.util.regex.Pattern; /* loaded from: classes.dex */ final class zzat { private static int g; private static PendingIntent h; private final Context b; private final zzan c; private Messenger e; private zzl f; private final SimpleArrayMap> a = new SimpleArrayMap<>(); private Messenger d = new Messenger(new zzau(this, Looper.getMainLooper())); public zzat(Context context, zzan zzanVar) { this.b = context; this.c = zzanVar; } /* JADX INFO: Access modifiers changed from: private */ public final void a(Message message) { if (message != null) { Object obj = message.obj; if (obj instanceof Intent) { Intent intent = (Intent) obj; intent.setExtrasClassLoader(new zzl.zza()); if (intent.hasExtra("google.messenger")) { Parcelable parcelableExtra = intent.getParcelableExtra("google.messenger"); if (parcelableExtra instanceof zzl) { this.f = (zzl) parcelableExtra; } if (parcelableExtra instanceof Messenger) { this.e = (Messenger) parcelableExtra; } } Intent intent2 = (Intent) message.obj; String action = intent2.getAction(); if (!"com.google.android.c2dm.intent.REGISTRATION".equals(action)) { if (Log.isLoggable("FirebaseInstanceId", 3)) { String valueOf = String.valueOf(action); Log.d("FirebaseInstanceId", valueOf.length() != 0 ? "Unexpected response action: ".concat(valueOf) : new String("Unexpected response action: ")); return; } return; } String stringExtra = intent2.getStringExtra("registration_id"); if (stringExtra == null) { stringExtra = intent2.getStringExtra("unregistered"); } if (stringExtra != null) { Matcher matcher = Pattern.compile("\\|ID\\|([^|]+)\\|:?+(.*)").matcher(stringExtra); if (!matcher.matches()) { if (Log.isLoggable("FirebaseInstanceId", 3)) { String valueOf2 = String.valueOf(stringExtra); Log.d("FirebaseInstanceId", valueOf2.length() != 0 ? "Unexpected response string: ".concat(valueOf2) : new String("Unexpected response string: ")); return; } return; } String group = matcher.group(1); String group2 = matcher.group(2); Bundle extras = intent2.getExtras(); extras.putString("registration_id", group2); a(group, extras); return; } String stringExtra2 = intent2.getStringExtra(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR); if (stringExtra2 == null) { String valueOf3 = String.valueOf(intent2.getExtras()); StringBuilder sb = new StringBuilder(String.valueOf(valueOf3).length() + 49); sb.append("Unexpected response, no error or registration id "); sb.append(valueOf3); Log.w("FirebaseInstanceId", sb.toString()); return; } if (Log.isLoggable("FirebaseInstanceId", 3)) { String valueOf4 = String.valueOf(stringExtra2); Log.d("FirebaseInstanceId", valueOf4.length() != 0 ? "Received InstanceID error ".concat(valueOf4) : new String("Received InstanceID error ")); } if (!stringExtra2.startsWith("|")) { synchronized (this.a) { for (int i = 0; i < this.a.size(); i++) { a(this.a.b(i), intent2.getExtras()); } } return; } String[] split = stringExtra2.split("\\|"); if (split.length <= 2 || !"ID".equals(split[1])) { String valueOf5 = String.valueOf(stringExtra2); Log.w("FirebaseInstanceId", valueOf5.length() != 0 ? "Unexpected structured response ".concat(valueOf5) : new String("Unexpected structured response ")); return; } String str = split[2]; String str2 = split[3]; if (str2.startsWith(":")) { str2 = str2.substring(1); } a(str, intent2.putExtra(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR, str2).getExtras()); return; } } Log.w("FirebaseInstanceId", "Dropping invalid message"); } private final Bundle b(Bundle bundle) throws IOException { Bundle c = c(bundle); if (c == null || !c.containsKey("google.messenger")) { return c; } Bundle c2 = c(bundle); if (c2 == null || !c2.containsKey("google.messenger")) { return c2; } return null; } /* JADX WARN: Code restructure failed: missing block: B:17:0x00a3, code lost: if (r7.f != null) goto L19; */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:25:0x00ef A[EXC_TOP_SPLITTER, SYNTHETIC] */ /* JADX WARN: Type inference failed for: r1v0, types: [com.google.android.gms.tasks.TaskCompletionSource, java.lang.Object] */ /* JADX WARN: Type inference failed for: r1v1 */ /* JADX WARN: Type inference failed for: r1v7 */ /* JADX WARN: Type inference failed for: r8v10 */ /* JADX WARN: Type inference failed for: r8v21, types: [android.os.Bundle] */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:20:0x00d3 -> B:21:0x00de). Please report as a decompilation issue!!! */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:54:0x00d9 -> B:21:0x00de). Please report as a decompilation issue!!! */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private final android.os.Bundle c(android.os.Bundle r8) throws java.io.IOException { /* Method dump skipped, instructions count: 297 To view this dump change 'Code comments level' option to 'DEBUG' */ throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.iid.zzat.c(android.os.Bundle):android.os.Bundle"); } private static synchronized void a(Context context, Intent intent) { synchronized (zzat.class) { if (h == null) { Intent intent2 = new Intent(); intent2.setPackage("com.google.example.invalidpackage"); h = PendingIntent.getBroadcast(context, 0, intent2, 0); } intent.putExtra("app", h); } } private final void a(String str, Bundle bundle) { synchronized (this.a) { TaskCompletionSource remove = this.a.remove(str); if (remove == null) { String valueOf = String.valueOf(str); Log.w("FirebaseInstanceId", valueOf.length() != 0 ? "Missing callback for ".concat(valueOf) : new String("Missing callback for ")); } else { remove.a((TaskCompletionSource) bundle); } } } final Bundle a(Bundle bundle) throws IOException { if (this.c.d() >= 12000000) { try { return (Bundle) Tasks.a((Task) zzab.a(this.b).a(1, bundle)); } catch (InterruptedException | ExecutionException e) { if (Log.isLoggable("FirebaseInstanceId", 3)) { String valueOf = String.valueOf(e); StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 22); sb.append("Error making request: "); sb.append(valueOf); Log.d("FirebaseInstanceId", sb.toString()); } if ((e.getCause() instanceof zzal) && ((zzal) e.getCause()).getErrorCode() == 4) { return b(bundle); } return null; } } return b(bundle); } private static synchronized String a() { String num; synchronized (zzat.class) { int i = g; g = i + 1; num = Integer.toString(i); } return num; } }