2022-06-10 21:38:30 +09:00

605 lines
19 KiB
Smali

.class public final Lcom/google/common/util/concurrent/ServiceManager;
.super Ljava/lang/Object;
.source "ServiceManager.java"
# interfaces
.implements Lcom/google/common/util/concurrent/ServiceManagerBridge;
# annotations
.annotation build Lcom/google/common/annotations/GwtIncompatible;
.end annotation
.annotation runtime Lcom/google/common/util/concurrent/ElementTypesAreNonnullByDefault;
.end annotation
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/google/common/util/concurrent/ServiceManager$EmptyServiceManagerWarning;,
Lcom/google/common/util/concurrent/ServiceManager$NoOpService;,
Lcom/google/common/util/concurrent/ServiceManager$ServiceListener;,
Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;,
Lcom/google/common/util/concurrent/ServiceManager$Listener;
}
.end annotation
# static fields
.field private static final HEALTHY_EVENT:Lcom/google/common/util/concurrent/ListenerCallQueue$Event;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lcom/google/common/util/concurrent/ListenerCallQueue$Event<",
"Lcom/google/common/util/concurrent/ServiceManager$Listener;",
">;"
}
.end annotation
.end field
.field private static final STOPPED_EVENT:Lcom/google/common/util/concurrent/ListenerCallQueue$Event;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lcom/google/common/util/concurrent/ListenerCallQueue$Event<",
"Lcom/google/common/util/concurrent/ServiceManager$Listener;",
">;"
}
.end annotation
.end field
.field private static final logger:Ljava/util/logging/Logger;
# instance fields
.field private final services:Lcom/google/common/collect/ImmutableList;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lcom/google/common/collect/ImmutableList<",
"Lcom/google/common/util/concurrent/Service;",
">;"
}
.end annotation
.end field
.field private final state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
# direct methods
.method public static constructor <clinit>()V
.locals 1
.line 1
const-class v0, Lcom/google/common/util/concurrent/ServiceManager;
invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Ljava/util/logging/Logger;->getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;
move-result-object v0
sput-object v0, Lcom/google/common/util/concurrent/ServiceManager;->logger:Ljava/util/logging/Logger;
.line 2
new-instance v0, Lcom/google/common/util/concurrent/ServiceManager$1;
invoke-direct {v0}, Lcom/google/common/util/concurrent/ServiceManager$1;-><init>()V
sput-object v0, Lcom/google/common/util/concurrent/ServiceManager;->HEALTHY_EVENT:Lcom/google/common/util/concurrent/ListenerCallQueue$Event;
.line 3
new-instance v0, Lcom/google/common/util/concurrent/ServiceManager$2;
invoke-direct {v0}, Lcom/google/common/util/concurrent/ServiceManager$2;-><init>()V
sput-object v0, Lcom/google/common/util/concurrent/ServiceManager;->STOPPED_EVENT:Lcom/google/common/util/concurrent/ListenerCallQueue$Event;
return-void
.end method
.method public constructor <init>(Ljava/lang/Iterable;)V
.locals 4
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/lang/Iterable<",
"+",
"Lcom/google/common/util/concurrent/Service;",
">;)V"
}
.end annotation
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 2
invoke-static {p1}, Lcom/google/common/collect/ImmutableList;->copyOf(Ljava/lang/Iterable;)Lcom/google/common/collect/ImmutableList;
move-result-object p1
.line 3
invoke-virtual {p1}, Ljava/util/AbstractCollection;->isEmpty()Z
move-result v0
if-eqz v0, :cond_0
.line 4
sget-object p1, Lcom/google/common/util/concurrent/ServiceManager;->logger:Ljava/util/logging/Logger;
sget-object v0, Ljava/util/logging/Level;->WARNING:Ljava/util/logging/Level;
new-instance v1, Lcom/google/common/util/concurrent/ServiceManager$EmptyServiceManagerWarning;
const/4 v2, 0x0
invoke-direct {v1, v2}, Lcom/google/common/util/concurrent/ServiceManager$EmptyServiceManagerWarning;-><init>(Lcom/google/common/util/concurrent/ServiceManager$1;)V
const-string v3, "ServiceManager configured with no services. Is your application configured properly?"
invoke-virtual {p1, v0, v3, v1}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
.line 5
new-instance p1, Lcom/google/common/util/concurrent/ServiceManager$NoOpService;
invoke-direct {p1, v2}, Lcom/google/common/util/concurrent/ServiceManager$NoOpService;-><init>(Lcom/google/common/util/concurrent/ServiceManager$1;)V
invoke-static {p1}, Lcom/google/common/collect/ImmutableList;->of(Ljava/lang/Object;)Lcom/google/common/collect/ImmutableList;
move-result-object p1
.line 6
:cond_0
new-instance v0, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-direct {v0, p1}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;-><init>(Lcom/google/common/collect/ImmutableCollection;)V
iput-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
.line 7
iput-object p1, p0, Lcom/google/common/util/concurrent/ServiceManager;->services:Lcom/google/common/collect/ImmutableList;
.line 8
new-instance v1, Ljava/lang/ref/WeakReference;
invoke-direct {v1, v0}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V
.line 9
invoke-virtual {p1}, Lcom/google/common/collect/ImmutableList;->iterator()Lcom/google/common/collect/UnmodifiableIterator;
move-result-object p1
:goto_0
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
move-result v0
if-eqz v0, :cond_2
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lcom/google/common/util/concurrent/Service;
.line 10
new-instance v2, Lcom/google/common/util/concurrent/ServiceManager$ServiceListener;
invoke-direct {v2, v0, v1}, Lcom/google/common/util/concurrent/ServiceManager$ServiceListener;-><init>(Lcom/google/common/util/concurrent/Service;Ljava/lang/ref/WeakReference;)V
invoke-static {}, Lcom/google/common/util/concurrent/MoreExecutors;->directExecutor()Ljava/util/concurrent/Executor;
move-result-object v3
invoke-interface {v0, v2, v3}, Lcom/google/common/util/concurrent/Service;->addListener(Lcom/google/common/util/concurrent/Service$Listener;Ljava/util/concurrent/Executor;)V
.line 11
invoke-interface {v0}, Lcom/google/common/util/concurrent/Service;->state()Lcom/google/common/util/concurrent/Service$State;
move-result-object v2
sget-object v3, Lcom/google/common/util/concurrent/Service$State;->NEW:Lcom/google/common/util/concurrent/Service$State;
if-ne v2, v3, :cond_1
const/4 v2, 0x1
goto :goto_1
:cond_1
const/4 v2, 0x0
:goto_1
const-string v3, "Can only manage NEW services, %s"
invoke-static {v2, v3, v0}, Lcom/google/common/base/Preconditions;->checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
goto :goto_0
.line 12
:cond_2
iget-object p1, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {p1}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->markReady()V
return-void
.end method
.method public static synthetic access$200()Ljava/util/logging/Logger;
.locals 1
.line 1
sget-object v0, Lcom/google/common/util/concurrent/ServiceManager;->logger:Ljava/util/logging/Logger;
return-object v0
.end method
.method public static synthetic access$300()Lcom/google/common/util/concurrent/ListenerCallQueue$Event;
.locals 1
.line 1
sget-object v0, Lcom/google/common/util/concurrent/ServiceManager;->STOPPED_EVENT:Lcom/google/common/util/concurrent/ListenerCallQueue$Event;
return-object v0
.end method
.method public static synthetic access$400()Lcom/google/common/util/concurrent/ListenerCallQueue$Event;
.locals 1
.line 1
sget-object v0, Lcom/google/common/util/concurrent/ServiceManager;->HEALTHY_EVENT:Lcom/google/common/util/concurrent/ListenerCallQueue$Event;
return-object v0
.end method
# virtual methods
.method public addListener(Lcom/google/common/util/concurrent/ServiceManager$Listener;Ljava/util/concurrent/Executor;)V
.locals 1
.line 1
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {v0, p1, p2}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->addListener(Lcom/google/common/util/concurrent/ServiceManager$Listener;Ljava/util/concurrent/Executor;)V
return-void
.end method
.method public awaitHealthy()V
.locals 1
.line 1
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {v0}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->awaitHealthy()V
return-void
.end method
.method public awaitHealthy(JLjava/util/concurrent/TimeUnit;)V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/util/concurrent/TimeoutException;
}
.end annotation
.line 2
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {v0, p1, p2, p3}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->awaitHealthy(JLjava/util/concurrent/TimeUnit;)V
return-void
.end method
.method public awaitStopped()V
.locals 1
.line 1
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {v0}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->awaitStopped()V
return-void
.end method
.method public awaitStopped(JLjava/util/concurrent/TimeUnit;)V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/util/concurrent/TimeoutException;
}
.end annotation
.line 2
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {v0, p1, p2, p3}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->awaitStopped(JLjava/util/concurrent/TimeUnit;)V
return-void
.end method
.method public isHealthy()Z
.locals 2
.line 1
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->services:Lcom/google/common/collect/ImmutableList;
invoke-virtual {v0}, Lcom/google/common/collect/ImmutableList;->iterator()Lcom/google/common/collect/UnmodifiableIterator;
move-result-object v0
:cond_0
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
move-result v1
if-eqz v1, :cond_1
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/google/common/util/concurrent/Service;
.line 2
invoke-interface {v1}, Lcom/google/common/util/concurrent/Service;->isRunning()Z
move-result v1
if-nez v1, :cond_0
const/4 v0, 0x0
return v0
:cond_1
const/4 v0, 0x1
return v0
.end method
.method public bridge synthetic servicesByState()Lcom/google/common/collect/ImmutableMultimap;
.locals 1
.line 1
invoke-virtual {p0}, Lcom/google/common/util/concurrent/ServiceManager;->servicesByState()Lcom/google/common/collect/ImmutableSetMultimap;
move-result-object v0
return-object v0
.end method
.method public servicesByState()Lcom/google/common/collect/ImmutableSetMultimap;
.locals 1
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Lcom/google/common/collect/ImmutableSetMultimap<",
"Lcom/google/common/util/concurrent/Service$State;",
"Lcom/google/common/util/concurrent/Service;",
">;"
}
.end annotation
.line 2
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {v0}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->servicesByState()Lcom/google/common/collect/ImmutableSetMultimap;
move-result-object v0
return-object v0
.end method
.method public startAsync()Lcom/google/common/util/concurrent/ServiceManager;
.locals 7
.annotation build Lcom/google/errorprone/annotations/CanIgnoreReturnValue;
.end annotation
.line 1
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->services:Lcom/google/common/collect/ImmutableList;
invoke-virtual {v0}, Lcom/google/common/collect/ImmutableList;->iterator()Lcom/google/common/collect/UnmodifiableIterator;
move-result-object v0
:goto_0
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
move-result v1
if-eqz v1, :cond_1
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/google/common/util/concurrent/Service;
.line 2
invoke-interface {v1}, Lcom/google/common/util/concurrent/Service;->state()Lcom/google/common/util/concurrent/Service$State;
move-result-object v2
.line 3
sget-object v3, Lcom/google/common/util/concurrent/Service$State;->NEW:Lcom/google/common/util/concurrent/Service$State;
if-ne v2, v3, :cond_0
const/4 v3, 0x1
goto :goto_1
:cond_0
const/4 v3, 0x0
:goto_1
const-string v4, "Service %s is %s, cannot start it."
invoke-static {v3, v4, v1, v2}, Lcom/google/common/base/Preconditions;->checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
goto :goto_0
.line 4
:cond_1
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->services:Lcom/google/common/collect/ImmutableList;
invoke-virtual {v0}, Lcom/google/common/collect/ImmutableList;->iterator()Lcom/google/common/collect/UnmodifiableIterator;
move-result-object v0
:goto_2
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
move-result v1
if-eqz v1, :cond_2
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/google/common/util/concurrent/Service;
.line 5
:try_start_0
iget-object v2, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {v2, v1}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->tryStartTiming(Lcom/google/common/util/concurrent/Service;)V
.line 6
invoke-interface {v1}, Lcom/google/common/util/concurrent/Service;->startAsync()Lcom/google/common/util/concurrent/Service;
:try_end_0
.catch Ljava/lang/IllegalStateException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_2
:catch_0
move-exception v2
.line 7
sget-object v3, Lcom/google/common/util/concurrent/ServiceManager;->logger:Ljava/util/logging/Logger;
sget-object v4, Ljava/util/logging/Level;->WARNING:Ljava/util/logging/Level;
invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/String;->length()I
move-result v5
add-int/lit8 v5, v5, 0x18
const-string v6, "Unable to start Service "
invoke-static {v5, v6, v1}, Lcom/android/billingclient/api/e;->a(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
invoke-virtual {v3, v4, v1, v2}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
goto :goto_2
:cond_2
return-object p0
.end method
.method public startupTimes()Lcom/google/common/collect/ImmutableMap;
.locals 1
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Lcom/google/common/collect/ImmutableMap<",
"Lcom/google/common/util/concurrent/Service;",
"Ljava/lang/Long;",
">;"
}
.end annotation
.line 1
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->state:Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;
invoke-virtual {v0}, Lcom/google/common/util/concurrent/ServiceManager$ServiceManagerState;->startupTimes()Lcom/google/common/collect/ImmutableMap;
move-result-object v0
return-object v0
.end method
.method public stopAsync()Lcom/google/common/util/concurrent/ServiceManager;
.locals 2
.annotation build Lcom/google/errorprone/annotations/CanIgnoreReturnValue;
.end annotation
.line 1
iget-object v0, p0, Lcom/google/common/util/concurrent/ServiceManager;->services:Lcom/google/common/collect/ImmutableList;
invoke-virtual {v0}, Lcom/google/common/collect/ImmutableList;->iterator()Lcom/google/common/collect/UnmodifiableIterator;
move-result-object v0
:goto_0
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
move-result v1
if-eqz v1, :cond_0
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/google/common/util/concurrent/Service;
.line 2
invoke-interface {v1}, Lcom/google/common/util/concurrent/Service;->stopAsync()Lcom/google/common/util/concurrent/Service;
goto :goto_0
:cond_0
return-object p0
.end method
.method public toString()Ljava/lang/String;
.locals 3
.line 1
const-class v0, Lcom/google/common/util/concurrent/ServiceManager;
invoke-static {v0}, Lcom/google/common/base/MoreObjects;->toStringHelper(Ljava/lang/Class;)Lcom/google/common/base/MoreObjects$ToStringHelper;
move-result-object v0
iget-object v1, p0, Lcom/google/common/util/concurrent/ServiceManager;->services:Lcom/google/common/collect/ImmutableList;
const-class v2, Lcom/google/common/util/concurrent/ServiceManager$NoOpService;
.line 2
invoke-static {v2}, Lcom/google/common/base/Predicates;->instanceOf(Ljava/lang/Class;)Lcom/google/common/base/Predicate;
move-result-object v2
invoke-static {v2}, Lcom/google/common/base/Predicates;->not(Lcom/google/common/base/Predicate;)Lcom/google/common/base/Predicate;
move-result-object v2
invoke-static {v1, v2}, Lcom/google/common/collect/Collections2;->filter(Ljava/util/Collection;Lcom/google/common/base/Predicate;)Ljava/util/Collection;
move-result-object v1
const-string v2, "services"
invoke-virtual {v0, v2, v1}, Lcom/google/common/base/MoreObjects$ToStringHelper;->add(Ljava/lang/String;Ljava/lang/Object;)Lcom/google/common/base/MoreObjects$ToStringHelper;
move-result-object v0
.line 3
invoke-virtual {v0}, Lcom/google/common/base/MoreObjects$ToStringHelper;->toString()Ljava/lang/String;
move-result-object v0
return-object v0
.end method