.class public Lcom/helpshift/poller/FetchNotificationUpdate; .super Ljava/lang/Object; .source "SourceFile" # instance fields .field public device:Lcom/helpshift/platform/Device; .field public genericDataManager:Lcom/helpshift/storage/HSGenericDataManager; .field public hsEventProxy:Lcom/helpshift/chat/HSEventProxy; .field public httpTransport:Lcom/helpshift/network/HTTPTransport; .field public notificationManager:Lcom/helpshift/notification/CoreNotificationManager; .field public persistentStorage:Lcom/helpshift/storage/HSPersistentStorage; .field public userManager:Lcom/helpshift/user/UserManager; # direct methods .method public constructor (Lcom/helpshift/platform/Device;Lcom/helpshift/storage/HSPersistentStorage;Lcom/helpshift/storage/HSGenericDataManager;Lcom/helpshift/user/UserManager;Lcom/helpshift/notification/CoreNotificationManager;Lcom/helpshift/network/HTTPTransport;Lcom/helpshift/chat/HSEventProxy;)V .locals 0 .line 49 invoke-direct {p0}, Ljava/lang/Object;->()V iput-object p1, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->device:Lcom/helpshift/platform/Device; iput-object p2, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->persistentStorage:Lcom/helpshift/storage/HSPersistentStorage; iput-object p3, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->genericDataManager:Lcom/helpshift/storage/HSGenericDataManager; iput-object p4, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; iput-object p5, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->notificationManager:Lcom/helpshift/notification/CoreNotificationManager; iput-object p6, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->httpTransport:Lcom/helpshift/network/HTTPTransport; iput-object p7, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->hsEventProxy:Lcom/helpshift/chat/HSEventProxy; return-void .end method # virtual methods .method public execute()I .locals 12 const-string v0, "Fetching notification count from network." const-string v1, "ftchNotif" .line 61 invoke-static {v1, v0}, Lcom/helpshift/log/HSLogger;->d(Ljava/lang/String;Ljava/lang/String;)V iget-object v0, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->genericDataManager:Lcom/helpshift/storage/HSGenericDataManager; .line 62 invoke-virtual {v0}, Lcom/helpshift/storage/HSGenericDataManager;->getNetworkHeaders()Ljava/util/Map; move-result-object v0 iget-object v2, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->genericDataManager:Lcom/helpshift/storage/HSGenericDataManager; .line 63 invoke-virtual {v2}, Lcom/helpshift/storage/HSGenericDataManager;->getPollingRoute()Ljava/lang/String; move-result-object v2 iget-object v3, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 65 invoke-virtual {v3}, Lcom/helpshift/user/UserManager;->getActiveUserDataForNetworkCall()Ljava/util/Map; move-result-object v3 .line 68 invoke-static {v3}, Lcom/helpshift/util/Utils;->isEmpty(Ljava/util/Map;)Z move-result v4 const/4 v5, -0x1 if-nez v4, :cond_5 invoke-static {v0}, Lcom/helpshift/util/Utils;->isEmpty(Ljava/util/Map;)Z move-result v4 if-nez v4, :cond_5 invoke-static {v2}, Lcom/helpshift/util/Utils;->isEmpty(Ljava/lang/String;)Z move-result v4 if-eqz v4, :cond_0 goto/16 :goto_6 :cond_0 iget-object v4, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 73 invoke-virtual {v4}, Lcom/helpshift/user/UserManager;->getPollerCursor()J move-result-wide v6 const-wide/16 v8, 0x0 cmp-long v4, v6, v8 if-eqz v4, :cond_1 const-string v4, "cursor" .line 75 invoke-static {v6, v7}, Ljava/lang/String;->valueOf(J)Ljava/lang/String; move-result-object v6 invoke-interface {v3, v4, v6}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; :cond_1 iget-object v4, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->device:Lcom/helpshift/platform/Device; .line 77 invoke-interface {v4}, Lcom/helpshift/platform/Device;->getDeviceId()Ljava/lang/String; move-result-object v4 const-string v6, "did" invoke-interface {v3, v6, v4}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; iget-object v4, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->persistentStorage:Lcom/helpshift/storage/HSPersistentStorage; .line 78 invoke-virtual {v4}, Lcom/helpshift/storage/HSPersistentStorage;->getPlatformId()Ljava/lang/String; move-result-object v4 const-string v6, "platform-id" invoke-interface {v3, v6, v4}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; .line 80 new-instance v4, Lcom/helpshift/network/GETNetwork; iget-object v6, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->httpTransport:Lcom/helpshift/network/HTTPTransport; invoke-direct {v4, v6, v2}, Lcom/helpshift/network/GETNetwork;->(Lcom/helpshift/network/HTTPTransport;Ljava/lang/String;)V .line 81 new-instance v2, Lcom/helpshift/network/AuthenticationFailureNetwork; invoke-direct {v2, v4}, Lcom/helpshift/network/AuthenticationFailureNetwork;->(Lcom/helpshift/network/HSNetwork;)V .line 83 new-instance v4, Lcom/helpshift/network/HSRequestData; invoke-direct {v4, v0, v3}, Lcom/helpshift/network/HSRequestData;->(Ljava/util/Map;Ljava/util/Map;)V .line 86 :try_start_0 invoke-interface {v2, v4}, Lcom/helpshift/network/HSNetwork;->makeRequest(Lcom/helpshift/network/HSRequestData;)Lcom/helpshift/network/HSResponse; move-result-object v0 .line 88 invoke-virtual {v0}, Lcom/helpshift/network/HSResponse;->getResponseString()Ljava/lang/String; move-result-object v2 .line 89 new-instance v3, Lorg/json/JSONObject; invoke-direct {v3, v2}, Lorg/json/JSONObject;->(Ljava/lang/String;)V const-string v2, "uc" const/4 v4, 0x0 .line 91 invoke-virtual {v3, v2, v4}, Lorg/json/JSONObject;->optInt(Ljava/lang/String;I)I move-result v2 const-string v6, "bpi" const/16 v7, 0x1388 .line 92 invoke-virtual {v3, v6, v7}, Lorg/json/JSONObject;->optInt(Ljava/lang/String;I)I move-result v6 const-string v7, "mpi" const v10, 0xea60 .line 93 invoke-virtual {v3, v7, v10}, Lorg/json/JSONObject;->optInt(Ljava/lang/String;I)I move-result v7 const-string v10, "cp" .line 94 invoke-virtual {v3, v10, v4}, Lorg/json/JSONObject;->optBoolean(Ljava/lang/String;Z)Z move-result v10 const-string v11, "c" .line 95 invoke-virtual {v3, v11, v8, v9}, Lorg/json/JSONObject;->optLong(Ljava/lang/String;J)J move-result-wide v8 iget-object v3, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 97 invoke-virtual {v3, v6}, Lcom/helpshift/user/UserManager;->setPollingBaseInterval(I)V iget-object v3, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 98 invoke-virtual {v3, v7}, Lcom/helpshift/user/UserManager;->setPollingMaxInterval(I)V iget-object v3, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 99 invoke-virtual {v3, v10}, Lcom/helpshift/user/UserManager;->setShouldPollFlag(Z)V if-lez v2, :cond_2 iget-object v3, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 103 invoke-virtual {v3}, Lcom/helpshift/user/UserManager;->getUnreadNotificationCount()I move-result v3 add-int/2addr v3, v2 iget-object v6, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 104 invoke-virtual {v6, v2}, Lcom/helpshift/user/UserManager;->updateUnreadCountBy(I)V iget-object v2, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 108 invoke-virtual {v2}, Lcom/helpshift/user/UserManager;->isPushTokenSynced()Z move-result v2 if-nez v2, :cond_2 iget-object v2, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->notificationManager:Lcom/helpshift/notification/CoreNotificationManager; iget-object v6, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->genericDataManager:Lcom/helpshift/storage/HSGenericDataManager; .line 110 invoke-virtual {v6, v3}, Lcom/helpshift/storage/HSGenericDataManager;->getNotificationStringForCount(I)Ljava/lang/String; move-result-object v3 invoke-interface {v2, v3, v4}, Lcom/helpshift/notification/CoreNotificationManager;->showNotification(Ljava/lang/String;Z)V goto :goto_0 :catch_0 move-exception v0 goto :goto_1 :catch_1 move-exception v0 goto :goto_2 :catch_2 move-exception v0 goto :goto_4 :cond_2 :goto_0 iget-object v2, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->userManager:Lcom/helpshift/user/UserManager; .line 116 invoke-virtual {v2, v8, v9}, Lcom/helpshift/user/UserManager;->setPollerCursor(J)V .line 119 invoke-virtual {v0}, Lcom/helpshift/network/HSResponse;->getStatus()I move-result v0 :try_end_0 .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_2 .catch Lcom/helpshift/network/exception/HSRootApiException; {:try_start_0 .. :try_end_0} :catch_1 .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0 return v0 :goto_1 const-string v2, "Error in poller request" .line 134 invoke-static {v1, v2, v0}, Lcom/helpshift/log/HSLogger;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V goto :goto_5 :goto_2 iget-object v2, v0, Lcom/helpshift/network/exception/HSRootApiException;->exceptionType:Lcom/helpshift/network/exception/HSRootApiException$ExceptionType; .line 125 sget-object v3, Lcom/helpshift/network/exception/NetworkException;->INVALID_AUTH_TOKEN:Lcom/helpshift/network/exception/NetworkException; if-ne v2, v3, :cond_3 iget-object v2, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->hsEventProxy:Lcom/helpshift/chat/HSEventProxy; const-string v3, "invalid user auth token" .line 126 invoke-virtual {v2, v3}, Lcom/helpshift/chat/HSEventProxy;->sendAuthFailureEvent(Ljava/lang/String;)V goto :goto_3 .line 128 :cond_3 sget-object v3, Lcom/helpshift/network/exception/NetworkException;->AUTH_TOKEN_NOT_PROVIDED:Lcom/helpshift/network/exception/NetworkException; if-ne v2, v3, :cond_4 iget-object v2, p0, Lcom/helpshift/poller/FetchNotificationUpdate;->hsEventProxy:Lcom/helpshift/chat/HSEventProxy; const-string v3, "missing user auth token" .line 129 invoke-virtual {v2, v3}, Lcom/helpshift/chat/HSEventProxy;->sendAuthFailureEvent(Ljava/lang/String;)V :cond_4 :goto_3 const-string v2, "HSRootApiException in poller request" .line 131 invoke-static {v1, v2, v0}, Lcom/helpshift/log/HSLogger;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V goto :goto_5 :goto_4 const-string v2, "Error parsing poller response" .line 122 invoke-static {v1, v2, v0}, Lcom/helpshift/log/HSLogger;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V :goto_5 return v5 :cond_5 :goto_6 const-string v0, "Skipping notification count fetch. Invalid params for network call." .line 69 invoke-static {v1, v0}, Lcom/helpshift/log/HSLogger;->d(Ljava/lang/String;Ljava/lang/String;)V return v5 .end method