granularity level: instruction

		.class  Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;
.super Ljava/lang/Object;
.source "MetadataBackendRegistry.java"

.annotation system Ldalvik/annotation/EnclosingClass;
value = Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x8
name = "BackendFactoryProvider"
.end annotation

.field private final applicationContext:Landroid/content/Context;
.field private backendProviders:Ljava/util/Map;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/Map<",
"Ljava/lang/String;",
"Ljava/lang/String;",
">;"
}
.end annotation
.end field


.method constructor <init>(Landroid/content/Context;)V
	.locals 1

	invoke-direct {p0}, Ljava/lang/Object;-><init>()V
	const/4 v0, 0x0
	iput-object v0, p0, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->backendProviders:Ljava/util/Map;
	iput-object p1, p0, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->applicationContext:Landroid/content/Context;
	return-void
.end method

.method private discover(Landroid/content/Context;)Ljava/util/Map;
	.locals 8
	.annotation system Ldalvik/annotation/Signature;
	value = {
	"(",
	"Landroid/content/Context;",
	")",
	"Ljava/util/Map<",
	"Ljava/lang/String;",
	"Ljava/lang/String;",
	">;"
	}
	.end annotation

	invoke-static {p1}, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->getMetadata(Landroid/content/Context;)Landroid/os/Bundle;
	move-result-object p1
	if-nez p1, :cond_0
	const-string p1, "BackendRegistry"
	const-string v0, "Could not retrieve metadata, returning empty list of transport backends."
	invoke-static {p1, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
	invoke-static {}, Ljava/util/Collections;->emptyMap()Ljava/util/Map;
	move-result-object p1
	return-object p1
	:cond_0
	new-instance v0, Ljava/util/HashMap;
	invoke-direct {v0}, Ljava/util/HashMap;-><init>()V
	invoke-virtual {p1}, Landroid/os/Bundle;->keySet()Ljava/util/Set;
	move-result-object v1
	invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
	move-result-object v1
	:cond_1
	invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
	move-result v2
	if-eqz v2, :cond_3
	invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
	move-result-object v2
	check-cast v2, Ljava/lang/String;
	invoke-virtual {p1, v2}, Landroid/os/Bundle;->get(Ljava/lang/String;)Ljava/lang/Object;
	move-result-object v3
	instance-of v4, v3, Ljava/lang/String;
	if-eqz v4, :cond_1
	const-string v4, "backend:"
	invoke-virtual {v2, v4}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
	move-result v4
	if-eqz v4, :cond_1
	check-cast v3, Ljava/lang/String;
	const/4 v4, -0x1
	const-string v5, ","
	invoke-virtual {v3, v5, v4}, Ljava/lang/String;->split(Ljava/lang/String;I)[Ljava/lang/String;
	move-result-object v3
	array-length v4, v3
	const/4 v5, 0x0
	:goto_0
	if-ge v5, v4, :cond_1
	aget-object v6, v3, v5
	invoke-virtual {v6}, Ljava/lang/String;->trim()Ljava/lang/String;
	move-result-object v6
	invoke-virtual {v6}, Ljava/lang/String;->isEmpty()Z
	move-result v7
	if-eqz v7, :cond_2
	goto :goto_1
	:cond_2
	const/16 v7, 0x8
	invoke-virtual {v2, v7}, Ljava/lang/String;->substring(I)Ljava/lang/String;
	move-result-object v7
	invoke-interface {v0, v6, v7}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
	:goto_1
	add-int/lit8 v5, v5, 0x1
	goto :goto_0
	:cond_3
	return-object v0
.end method

.method private getBackendProviders()Ljava/util/Map;
	.locals 1
	.annotation system Ldalvik/annotation/Signature;
	value = {
	"()",
	"Ljava/util/Map<",
	"Ljava/lang/String;",
	"Ljava/lang/String;",
	">;"
	}
	.end annotation

	iget-object v0, p0, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->backendProviders:Ljava/util/Map;
	if-nez v0, :cond_0
	iget-object v0, p0, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->applicationContext:Landroid/content/Context;
	invoke-direct {p0, v0}, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->discover(Landroid/content/Context;)Ljava/util/Map;
	move-result-object v0
	iput-object v0, p0, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->backendProviders:Ljava/util/Map;
	:cond_0
	iget-object v0, p0, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->backendProviders:Ljava/util/Map;
	return-object v0
.end method

.method private static getMetadata(Landroid/content/Context;)Landroid/os/Bundle;
	.locals 5

	const-string v0, "BackendRegistry"
	const/4 v1, 0x0
	:try_start_0
	invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;
	move-result-object v2
	if-nez v2, :cond_0
	const-string p0, "Context has no PackageManager."
	invoke-static {v0, p0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
	return-object v1
	:cond_0
	new-instance v3, Landroid/content/ComponentName;
	const-class v4, Lcom/google/android/datatransport/runtime/backends/TransportBackendDiscovery;
	invoke-direct {v3, p0, v4}, Landroid/content/ComponentName;-><init>(Landroid/content/Context;Ljava/lang/Class;)V
	const/16 p0, 0x80
	invoke-virtual {v2, v3, p0}, Landroid/content/pm/PackageManager;->getServiceInfo(Landroid/content/ComponentName;I)Landroid/content/pm/ServiceInfo;
	move-result-object p0
	if-nez p0, :cond_1
	const-string p0, "TransportBackendDiscovery has no service info."
	invoke-static {v0, p0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
	return-object v1
	:cond_1
	iget-object p0, p0, Landroid/content/pm/ServiceInfo;->metaData:Landroid/os/Bundle;
	:try_end_0
	.catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
	return-object p0
	:catch_0
	const-string p0, "Application info not found."
	invoke-static {v0, p0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
	return-object v1
.end method

.method  get(Ljava/lang/String;)Lcom/google/android/datatransport/runtime/backends/BackendFactory;
	.locals 8

	const-string v0, "Could not instantiate %s"
	const-string v1, "Could not instantiate %s."
	const-string v2, "BackendRegistry"
	invoke-direct {p0}, Lcom/google/android/datatransport/runtime/backends/MetadataBackendRegistry$BackendFactoryProvider;->getBackendProviders()Ljava/util/Map;
	move-result-object v3
	invoke-interface {v3, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;
	move-result-object p1
	check-cast p1, Ljava/lang/String;
	const/4 v3, 0x0
	if-nez p1, :cond_0
	return-object v3
	:cond_0
	const/4 v4, 0x1
	const/4 v5, 0x0
	:try_start_0
	invoke-static {p1}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
	move-result-object v6
	const-class v7, Lcom/google/android/datatransport/runtime/backends/BackendFactory;
	invoke-virtual {v6, v7}, Ljava/lang/Class;->asSubclass(Ljava/lang/Class;)Ljava/lang/Class;
	move-result-object v6
	new-array v7, v5, [Ljava/lang/Class;
	invoke-virtual {v6, v7}, Ljava/lang/Class;->getDeclaredConstructor([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
	move-result-object v6
	new-array v7, v5, [Ljava/lang/Object;
	invoke-virtual {v6, v7}, Ljava/lang/reflect/Constructor;->newInstance([Ljava/lang/Object;)Ljava/lang/Object;
	move-result-object v6
	check-cast v6, Lcom/google/android/datatransport/runtime/backends/BackendFactory;
	:try_end_0
	.catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_4
	.catch Ljava/lang/IllegalAccessException; {:try_start_0 .. :try_end_0} :catch_3
	.catch Ljava/lang/InstantiationException; {:try_start_0 .. :try_end_0} :catch_2
	.catch Ljava/lang/NoSuchMethodException; {:try_start_0 .. :try_end_0} :catch_1
	.catch Ljava/lang/reflect/InvocationTargetException; {:try_start_0 .. :try_end_0} :catch_0
	return-object v6
	:catch_0
	move-exception v1
	new-array v4, v4, [Ljava/lang/Object;
	aput-object p1, v4, v5
	invoke-static {v0, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
	move-result-object p1
	invoke-static {v2, p1, v1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
	goto :goto_0
	:catch_1
	move-exception v1
	new-array v4, v4, [Ljava/lang/Object;
	aput-object p1, v4, v5
	invoke-static {v0, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
	move-result-object p1
	invoke-static {v2, p1, v1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
	goto :goto_0
	:catch_2
	move-exception v0
	new-array v4, v4, [Ljava/lang/Object;
	aput-object p1, v4, v5
	invoke-static {v1, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
	move-result-object p1
	invoke-static {v2, p1, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
	goto :goto_0
	:catch_3
	move-exception v0
	new-array v4, v4, [Ljava/lang/Object;
	aput-object p1, v4, v5
	invoke-static {v1, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
	move-result-object p1
	invoke-static {v2, p1, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
	goto :goto_0
	:catch_4
	move-exception v0
	new-array v1, v4, [Ljava/lang/Object;
	aput-object p1, v1, v5
	const-string p1, "Class %s is not found."
	invoke-static {p1, v1}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
	move-result-object p1
	invoke-static {v2, p1, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
	:goto_0
	return-object v3
.end method