granularity level: instruction

		.class public Lcom/google/firebase/messaging/ServiceStarter;
.super Ljava/lang/Object;
.source "ServiceStarter.java"


.field static final ACTION_MESSAGING_EVENT:Ljava/lang/String; = "com.google.firebase.MESSAGING_EVENT"
.field static final ERROR_ILLEGAL_STATE_EXCEPTION:I = 0x192
.field static final ERROR_ILLEGAL_STATE_EXCEPTION_FALLBACK_TO_BIND:I = 0x193
.field static final ERROR_NOT_FOUND:I = 0x194
.field static final ERROR_SECURITY_EXCEPTION:I = 0x191
.field public static final ERROR_UNKNOWN:I = 0x1f4
.field private static final EXTRA_WRAPPED_INTENT:Ljava/lang/String; = "wrapped_intent"
.field private static final PERMISSIONS_MISSING_HINT:Ljava/lang/String; = "this should normally be included by the manifest merger, but may needed to be manually added to your manifest"
.field public static final SUCCESS:I = -0x1
.field private static instance:Lcom/google/firebase/messaging/ServiceStarter;
.field private firebaseMessagingServiceClassName:Ljava/lang/String;
.field private hasAccessNetworkStatePermission:Ljava/lang/Boolean;
.field private hasWakeLockPermission:Ljava/lang/Boolean;
.field private final messagingEvents:Ljava/util/Queue;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/Queue<",
"Landroid/content/Intent;",
">;"
}
.end annotation
.end field


.method private constructor <init>()V
	.locals 1

	invoke-direct {p0}, Ljava/lang/Object;-><init>()V
	const/4 v0, 0x0
	iput-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->firebaseMessagingServiceClassName:Ljava/lang/String;
	iput-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasWakeLockPermission:Ljava/lang/Boolean;
	iput-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasAccessNetworkStatePermission:Ljava/lang/Boolean;
	new-instance v0, Ljava/util/ArrayDeque;
	invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
	iput-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->messagingEvents:Ljava/util/Queue;
	return-void
.end method

.method private doStartService(Landroid/content/Context;Landroid/content/Intent;)I
	.locals 4

	invoke-direct {p0, p1, p2}, Lcom/google/firebase/messaging/ServiceStarter;->resolveServiceClassName(Landroid/content/Context;Landroid/content/Intent;)Ljava/lang/String;
	move-result-object v0
	const-string v1, "FirebaseMessaging"
	if-eqz v0, :cond_1
	const/4 v2, 0x3
	invoke-static {v1, v2}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z
	move-result v2
	invoke-virtual {p1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
	move-result-object v2
	invoke-virtual {p2, v2, v0}, Landroid/content/Intent;->setClassName(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
	:cond_1
	invoke-virtual {p0, p1}, Lcom/google/firebase/messaging/ServiceStarter;->hasWakeLockPermission(Landroid/content/Context;)Z
	move-result v0
	invoke-static {p1, p2}, Lcom/google/firebase/messaging/WakeLockHolder;->startWakefulService(Landroid/content/Context;Landroid/content/Intent;)Landroid/content/ComponentName;
	move-result-object p1
	const/4 p1, -0x1
	return p1
.end method

.method static declared-synchronized getInstance()Lcom/google/firebase/messaging/ServiceStarter;
	.locals 2

	const-class v0, Lcom/google/firebase/messaging/ServiceStarter;
	monitor-enter v0
	:try_start_0
	sget-object v1, Lcom/google/firebase/messaging/ServiceStarter;->instance:Lcom/google/firebase/messaging/ServiceStarter;
	if-nez v1, :cond_0
	new-instance v1, Lcom/google/firebase/messaging/ServiceStarter;
	invoke-direct {v1}, Lcom/google/firebase/messaging/ServiceStarter;-><init>()V
	sput-object v1, Lcom/google/firebase/messaging/ServiceStarter;->instance:Lcom/google/firebase/messaging/ServiceStarter;
	:cond_0
	sget-object v1, Lcom/google/firebase/messaging/ServiceStarter;->instance:Lcom/google/firebase/messaging/ServiceStarter;
	:try_end_0
	.catchall {:try_start_0 .. :try_end_0} :catchall_0
	monitor-exit v0
	return-object v1
	:catchall_0
	move-exception v1
	monitor-exit v0
	throw v1
.end method

.method private declared-synchronized resolveServiceClassName(Landroid/content/Context;Landroid/content/Intent;)Ljava/lang/String;
	.locals 3

	monitor-enter p0
	:try_start_0
	iget-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->firebaseMessagingServiceClassName:Ljava/lang/String;
	:try_end_0
	.catchall {:try_start_0 .. :try_end_0} :catchall_0
	if-eqz v0, :cond_0
	monitor-exit p0
	return-object v0
	:try_start_1
	:cond_0
	invoke-virtual {p1}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;
	move-result-object v0
	const/4 v1, 0x0
	invoke-virtual {v0, p2, v1}, Landroid/content/pm/PackageManager;->resolveService(Landroid/content/Intent;I)Landroid/content/pm/ResolveInfo;
	move-result-object p2
	const/4 v0, 0x0
	iget-object v1, p2, Landroid/content/pm/ResolveInfo;->serviceInfo:Landroid/content/pm/ServiceInfo;
	iget-object p2, p2, Landroid/content/pm/ResolveInfo;->serviceInfo:Landroid/content/pm/ServiceInfo;
	invoke-virtual {p1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
	move-result-object v1
	iget-object v2, p2, Landroid/content/pm/ServiceInfo;->packageName:Ljava/lang/String;
	invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
	move-result v1
	iget-object v1, p2, Landroid/content/pm/ServiceInfo;->name:Ljava/lang/String;
	iget-object v0, p2, Landroid/content/pm/ServiceInfo;->name:Ljava/lang/String;
	const-string v1, "."
	invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
	move-result v0
	iget-object p1, p2, Landroid/content/pm/ServiceInfo;->name:Ljava/lang/String;
	iput-object p1, p0, Lcom/google/firebase/messaging/ServiceStarter;->firebaseMessagingServiceClassName:Ljava/lang/String;
	:goto_0
	iget-object p1, p0, Lcom/google/firebase/messaging/ServiceStarter;->firebaseMessagingServiceClassName:Ljava/lang/String;
	:try_end_1
	.catchall {:try_start_1 .. :try_end_1} :catchall_0
	monitor-exit p0
	return-object p1
	:catchall_0
	move-exception p1
	monitor-exit p0
	throw p1
.end method

.method public static setForTesting(Lcom/google/firebase/messaging/ServiceStarter;)V
	.locals 0

	return-void
.end method

.method  getMessagingEvent()Landroid/content/Intent;
	.locals 1

	iget-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->messagingEvents:Ljava/util/Queue;
	invoke-interface {v0}, Ljava/util/Queue;->poll()Ljava/lang/Object;
	move-result-object v0
	check-cast v0, Landroid/content/Intent;
	return-object v0
.end method

.method  hasAccessNetworkStatePermission(Landroid/content/Context;)Z
	.locals 1

	iget-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasAccessNetworkStatePermission:Ljava/lang/Boolean;
	if-nez v0, :cond_1
	const-string v0, "android.permission.ACCESS_NETWORK_STATE"
	invoke-virtual {p1, v0}, Landroid/content/Context;->checkCallingOrSelfPermission(Ljava/lang/String;)I
	move-result p1
	const/4 p1, 0x1
	invoke-static {p1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
	move-result-object p1
	iput-object p1, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasAccessNetworkStatePermission:Ljava/lang/Boolean;
	:cond_1
	iget-object p1, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasWakeLockPermission:Ljava/lang/Boolean;
	invoke-virtual {p1}, Ljava/lang/Boolean;->booleanValue()Z
	move-result p1
	iget-object p1, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasAccessNetworkStatePermission:Ljava/lang/Boolean;
	invoke-virtual {p1}, Ljava/lang/Boolean;->booleanValue()Z
	move-result p1
	return p1
.end method

.method  hasWakeLockPermission(Landroid/content/Context;)Z
	.locals 1

	iget-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasWakeLockPermission:Ljava/lang/Boolean;
	if-nez v0, :cond_1
	const-string v0, "android.permission.WAKE_LOCK"
	invoke-virtual {p1, v0}, Landroid/content/Context;->checkCallingOrSelfPermission(Ljava/lang/String;)I
	move-result p1
	const/4 p1, 0x1
	invoke-static {p1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
	move-result-object p1
	iput-object p1, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasWakeLockPermission:Ljava/lang/Boolean;
	:cond_1
	iget-object p1, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasWakeLockPermission:Ljava/lang/Boolean;
	invoke-virtual {p1}, Ljava/lang/Boolean;->booleanValue()Z
	move-result p1
	iget-object p1, p0, Lcom/google/firebase/messaging/ServiceStarter;->hasWakeLockPermission:Ljava/lang/Boolean;
	invoke-virtual {p1}, Ljava/lang/Boolean;->booleanValue()Z
	move-result p1
	return p1
.end method

.method public startMessagingService(Landroid/content/Context;Landroid/content/Intent;)I
	.locals 2

	const-string v0, "FirebaseMessaging"
	const/4 v1, 0x3
	invoke-static {v0, v1}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z
	move-result v1
	iget-object v0, p0, Lcom/google/firebase/messaging/ServiceStarter;->messagingEvents:Ljava/util/Queue;
	invoke-interface {v0, p2}, Ljava/util/Queue;->offer(Ljava/lang/Object;)Z
	new-instance p2, Landroid/content/Intent;
	const-string v0, "com.google.firebase.MESSAGING_EVENT"
	invoke-direct {p2, v0}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
	invoke-virtual {p1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
	move-result-object v0
	invoke-virtual {p2, v0}, Landroid/content/Intent;->setPackage(Ljava/lang/String;)Landroid/content/Intent;
	invoke-direct {p0, p1, p2}, Lcom/google/firebase/messaging/ServiceStarter;->doStartService(Landroid/content/Context;Landroid/content/Intent;)I
	move-result p1
	return p1
.end method