package com.google.firebase.messaging; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.util.Log; import java.util.ArrayDeque; import java.util.Queue; /* loaded from: classes2.dex */ public class t0 { /* renamed from: e, reason: collision with root package name */ private static t0 f5659e; /* renamed from: a, reason: collision with root package name */ private String f5660a = null; /* renamed from: b, reason: collision with root package name */ private Boolean f5661b = null; /* renamed from: c, reason: collision with root package name */ private Boolean f5662c = null; /* renamed from: d, reason: collision with root package name */ private final Queue f5663d = new ArrayDeque(); private t0() { } private int a(Context context, Intent intent) { ComponentName startService; String f10 = f(context, intent); if (f10 != null) { if (Log.isLoggable("FirebaseMessaging", 3)) { Log.d("FirebaseMessaging", "Restricting intent to a specific service: " + f10); } intent.setClassName(context.getPackageName(), f10); } try { if (e(context)) { startService = e1.h(context, intent); } else { startService = context.startService(intent); Log.d("FirebaseMessaging", "Missing wake lock permission, service start may be delayed"); } if (startService != null) { return -1; } Log.e("FirebaseMessaging", "Error while delivering the message: ServiceIntent not found."); return 404; } catch (IllegalStateException e10) { Log.e("FirebaseMessaging", "Failed to start service while in background: " + e10); return 402; } catch (SecurityException e11) { Log.e("FirebaseMessaging", "Error while delivering the message to the serviceIntent", e11); return 401; } } static synchronized t0 b() { t0 t0Var; synchronized (t0.class) { if (f5659e == null) { f5659e = new t0(); } t0Var = f5659e; } return t0Var; } private synchronized String f(Context context, Intent intent) { ServiceInfo serviceInfo; String str; String str2 = this.f5660a; if (str2 != null) { return str2; } ResolveInfo resolveService = context.getPackageManager().resolveService(intent, 0); if (resolveService != null && (serviceInfo = resolveService.serviceInfo) != null) { if (context.getPackageName().equals(serviceInfo.packageName) && (str = serviceInfo.name) != null) { if (str.startsWith(".")) { this.f5660a = context.getPackageName() + serviceInfo.name; } else { this.f5660a = serviceInfo.name; } return this.f5660a; } Log.e("FirebaseMessaging", "Error resolving target intent service, skipping classname enforcement. Resolved service was: " + serviceInfo.packageName + "/" + serviceInfo.name); return null; } Log.e("FirebaseMessaging", "Failed to resolve target intent service, skipping classname enforcement"); return null; } Intent c() { return (Intent) this.f5663d.poll(); } boolean d(Context context) { if (this.f5662c == null) { this.f5662c = Boolean.valueOf(context.checkCallingOrSelfPermission("android.permission.ACCESS_NETWORK_STATE") == 0); } if (!this.f5661b.booleanValue() && Log.isLoggable("FirebaseMessaging", 3)) { Log.d("FirebaseMessaging", "Missing Permission: android.permission.ACCESS_NETWORK_STATE this should normally be included by the manifest merger, but may needed to be manually added to your manifest"); } return this.f5662c.booleanValue(); } boolean e(Context context) { if (this.f5661b == null) { this.f5661b = Boolean.valueOf(context.checkCallingOrSelfPermission("android.permission.WAKE_LOCK") == 0); } if (!this.f5661b.booleanValue() && Log.isLoggable("FirebaseMessaging", 3)) { Log.d("FirebaseMessaging", "Missing Permission: android.permission.WAKE_LOCK this should normally be included by the manifest merger, but may needed to be manually added to your manifest"); } return this.f5661b.booleanValue(); } public int g(Context context, Intent intent) { if (Log.isLoggable("FirebaseMessaging", 3)) { Log.d("FirebaseMessaging", "Starting service"); } this.f5663d.offer(intent); Intent intent2 = new Intent("com.google.firebase.MESSAGING_EVENT"); intent2.setPackage(context.getPackageName()); return a(context, intent2); } }