granularity level: instruction
.class final Lcom/google/firebase/messaging/TopicsStore;
.super Ljava/lang/Object;
.source "TopicsStore.java"
.field private static final DIVIDER_QUEUE_OPERATIONS:Ljava/lang/String; = ","
.field static final KEY_TOPIC_OPERATIONS_QUEUE:Ljava/lang/String; = "topic_operation_queue"
.field static final PREFERENCES:Ljava/lang/String; = "com.google.android.gms.appid"
.field private static topicsStoreWeakReference:Ljava/lang/ref/WeakReference;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/ref/WeakReference<",
"Lcom/google/firebase/messaging/TopicsStore;",
">;"
}
.end annotation
.end field
.field private final sharedPreferences:Landroid/content/SharedPreferences;
.field private final syncExecutor:Ljava/util/concurrent/Executor;
.field private topicOperationsQueue:Lcom/google/firebase/messaging/SharedPreferencesQueue;
.method private constructor <init>(Landroid/content/SharedPreferences;Ljava/util/concurrent/Executor;)V
.locals 0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p2, p0, Lcom/google/firebase/messaging/TopicsStore;->syncExecutor:Ljava/util/concurrent/Executor;
iput-object p1, p0, Lcom/google/firebase/messaging/TopicsStore;->sharedPreferences:Landroid/content/SharedPreferences;
return-void
.end method
.method static declared-synchronized clearCaches()V
.locals 2
const-class v0, Lcom/google/firebase/messaging/TopicsStore;
monitor-enter v0
:try_start_0
sget-object v1, Lcom/google/firebase/messaging/TopicsStore;->topicsStoreWeakReference:Ljava/lang/ref/WeakReference;
if-eqz v1, :cond_0
invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->clear()V
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
:cond_0
monitor-exit v0
return-void
:catchall_0
move-exception v1
monitor-exit v0
throw v1
.end method
.method public static declared-synchronized getInstance(Landroid/content/Context;Ljava/util/concurrent/Executor;)Lcom/google/firebase/messaging/TopicsStore;
.locals 3
const-class v0, Lcom/google/firebase/messaging/TopicsStore;
monitor-enter v0
const/4 v1, 0x0
:try_start_0
sget-object v2, Lcom/google/firebase/messaging/TopicsStore;->topicsStoreWeakReference:Ljava/lang/ref/WeakReference;
if-eqz v2, :cond_0
invoke-virtual {v2}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/google/firebase/messaging/TopicsStore;
:cond_0
if-nez v1, :cond_1
const-string v1, "com.google.android.gms.appid"
const/4 v2, 0x0
invoke-virtual {p0, v1, v2}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;
move-result-object p0
new-instance v1, Lcom/google/firebase/messaging/TopicsStore;
invoke-direct {v1, p0, p1}, Lcom/google/firebase/messaging/TopicsStore;-><init>(Landroid/content/SharedPreferences;Ljava/util/concurrent/Executor;)V
invoke-direct {v1}, Lcom/google/firebase/messaging/TopicsStore;->initStore()V
new-instance p0, Ljava/lang/ref/WeakReference;
invoke-direct {p0, v1}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V
sput-object p0, Lcom/google/firebase/messaging/TopicsStore;->topicsStoreWeakReference:Ljava/lang/ref/WeakReference;
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
:cond_1
monitor-exit v0
return-object v1
:catchall_0
move-exception p0
monitor-exit v0
throw p0
.end method
.method private declared-synchronized initStore()V
.locals 4
monitor-enter p0
:try_start_0
iget-object v0, p0, Lcom/google/firebase/messaging/TopicsStore;->sharedPreferences:Landroid/content/SharedPreferences;
const-string v1, "topic_operation_queue"
const-string v2, ","
iget-object v3, p0, Lcom/google/firebase/messaging/TopicsStore;->syncExecutor:Ljava/util/concurrent/Executor;
invoke-static {v0, v1, v2, v3}, Lcom/google/firebase/messaging/SharedPreferencesQueue;->createInstance(Landroid/content/SharedPreferences;Ljava/lang/String;Ljava/lang/String;Ljava/util/concurrent/Executor;)Lcom/google/firebase/messaging/SharedPreferencesQueue;
move-result-object v0
iput-object v0, p0, Lcom/google/firebase/messaging/TopicsStore;->topicOperationsQueue:Lcom/google/firebase/messaging/SharedPreferencesQueue;
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
monitor-exit p0
return-void
:catchall_0
move-exception v0
monitor-exit p0
throw v0
.end method
.method declared-synchronized addTopicOperation(Lcom/google/firebase/messaging/TopicOperation;)Z
.locals 1
monitor-enter p0
:try_start_0
iget-object v0, p0, Lcom/google/firebase/messaging/TopicsStore;->topicOperationsQueue:Lcom/google/firebase/messaging/SharedPreferencesQueue;
invoke-virtual {p1}, Lcom/google/firebase/messaging/TopicOperation;->serialize()Ljava/lang/String;
move-result-object p1
invoke-virtual {v0, p1}, Lcom/google/firebase/messaging/SharedPreferencesQueue;->add(Ljava/lang/String;)Z
move-result p1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
monitor-exit p0
return p1
:catchall_0
move-exception p1
monitor-exit p0
throw p1
.end method
.method declared-synchronized clearTopicOperations()V
.locals 1
monitor-enter p0
:try_start_0
iget-object v0, p0, Lcom/google/firebase/messaging/TopicsStore;->topicOperationsQueue:Lcom/google/firebase/messaging/SharedPreferencesQueue;
invoke-virtual {v0}, Lcom/google/firebase/messaging/SharedPreferencesQueue;->clear()V
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
monitor-exit p0
return-void
:catchall_0
move-exception v0
monitor-exit p0
throw v0
.end method
.method declared-synchronized getNextTopicOperation()Lcom/google/firebase/messaging/TopicOperation;
.locals 1
monitor-enter p0
:try_start_0
iget-object v0, p0, Lcom/google/firebase/messaging/TopicsStore;->topicOperationsQueue:Lcom/google/firebase/messaging/SharedPreferencesQueue;
invoke-virtual {v0}, Lcom/google/firebase/messaging/SharedPreferencesQueue;->peek()Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Lcom/google/firebase/messaging/TopicOperation;->from(Ljava/lang/String;)Lcom/google/firebase/messaging/TopicOperation;
move-result-object v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
monitor-exit p0
return-object v0
:catchall_0
move-exception v0
monitor-exit p0
throw v0
.end method
.method declared-synchronized getOperations()Ljava/util/List;
.locals 3
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Ljava/util/List<",
"Lcom/google/firebase/messaging/TopicOperation;",
">;"
}
.end annotation
monitor-enter p0
:try_start_0
iget-object v0, p0, Lcom/google/firebase/messaging/TopicsStore;->topicOperationsQueue:Lcom/google/firebase/messaging/SharedPreferencesQueue;
invoke-virtual {v0}, Lcom/google/firebase/messaging/SharedPreferencesQueue;->toList()Ljava/util/List;
move-result-object v0
new-instance v1, Ljava/util/ArrayList;
invoke-interface {v0}, Ljava/util/List;->size()I
move-result v2
invoke-direct {v1, v2}, Ljava/util/ArrayList;-><init>(I)V
invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v0
:goto_0
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
move-result v2
if-eqz v2, :cond_0
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v2
check-cast v2, Ljava/lang/String;
invoke-static {v2}, Lcom/google/firebase/messaging/TopicOperation;->from(Ljava/lang/String;)Lcom/google/firebase/messaging/TopicOperation;
move-result-object v2
invoke-interface {v1, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
goto :goto_0
:cond_0
monitor-exit p0
return-object v1
:catchall_0
move-exception v0
monitor-exit p0
throw v0
.end method
.method declared-synchronized pollTopicOperation()Lcom/google/firebase/messaging/TopicOperation;
.locals 2
monitor-enter p0
:try_start_0
iget-object v0, p0, Lcom/google/firebase/messaging/TopicsStore;->topicOperationsQueue:Lcom/google/firebase/messaging/SharedPreferencesQueue;
invoke-virtual {v0}, Lcom/google/firebase/messaging/SharedPreferencesQueue;->remove()Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Lcom/google/firebase/messaging/TopicOperation;->from(Ljava/lang/String;)Lcom/google/firebase/messaging/TopicOperation;
move-result-object v0
:try_end_0
.catch Ljava/util/NoSuchElementException; {:try_start_0 .. :try_end_0} :catch_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
monitor-exit p0
return-object v0
:catchall_0
move-exception v0
goto :goto_0
:try_start_1
:catch_0
const-string v0, "FirebaseMessaging"
const-string v1, "Polling operation queue failed"
invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
const/4 v0, 0x0
monitor-exit p0
return-object v0
:goto_0
monitor-exit p0
throw v0
.end method
.method declared-synchronized removeTopicOperation(Lcom/google/firebase/messaging/TopicOperation;)Z
.locals 1
monitor-enter p0
:try_start_0
iget-object v0, p0, Lcom/google/firebase/messaging/TopicsStore;->topicOperationsQueue:Lcom/google/firebase/messaging/SharedPreferencesQueue;
invoke-virtual {p1}, Lcom/google/firebase/messaging/TopicOperation;->serialize()Ljava/lang/String;
move-result-object p1
invoke-virtual {v0, p1}, Lcom/google/firebase/messaging/SharedPreferencesQueue;->remove(Ljava/lang/Object;)Z
move-result p1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
monitor-exit p0
return p1
:catchall_0
move-exception p1
monitor-exit p0
throw p1
.end method