- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
96 lines
4.9 KiB
Java
96 lines
4.9 KiB
Java
package com.helpshift.poller;
|
|
|
|
import com.helpshift.chat.HSEventProxy;
|
|
import com.helpshift.log.HSLogger;
|
|
import com.helpshift.network.AuthenticationFailureNetwork;
|
|
import com.helpshift.network.GETNetwork;
|
|
import com.helpshift.network.HSRequestData;
|
|
import com.helpshift.network.HSResponse;
|
|
import com.helpshift.network.HTTPTransport;
|
|
import com.helpshift.network.exception.HSRootApiException;
|
|
import com.helpshift.network.exception.NetworkException;
|
|
import com.helpshift.notification.CoreNotificationManager;
|
|
import com.helpshift.platform.Device;
|
|
import com.helpshift.storage.HSGenericDataManager;
|
|
import com.helpshift.storage.HSPersistentStorage;
|
|
import com.helpshift.user.UserManager;
|
|
import com.helpshift.util.Utils;
|
|
import com.mbridge.msdk.newreward.function.common.MBridgeCommon;
|
|
import java.util.Map;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class FetchNotificationUpdate {
|
|
public Device device;
|
|
public HSGenericDataManager genericDataManager;
|
|
public HSEventProxy hsEventProxy;
|
|
public HTTPTransport httpTransport;
|
|
public CoreNotificationManager notificationManager;
|
|
public HSPersistentStorage persistentStorage;
|
|
public UserManager userManager;
|
|
|
|
public FetchNotificationUpdate(Device device, HSPersistentStorage hSPersistentStorage, HSGenericDataManager hSGenericDataManager, UserManager userManager, CoreNotificationManager coreNotificationManager, HTTPTransport hTTPTransport, HSEventProxy hSEventProxy) {
|
|
this.device = device;
|
|
this.persistentStorage = hSPersistentStorage;
|
|
this.genericDataManager = hSGenericDataManager;
|
|
this.userManager = userManager;
|
|
this.notificationManager = coreNotificationManager;
|
|
this.httpTransport = hTTPTransport;
|
|
this.hsEventProxy = hSEventProxy;
|
|
}
|
|
|
|
public int execute() {
|
|
HSLogger.d("ftchNotif", "Fetching notification count from network.");
|
|
Map networkHeaders = this.genericDataManager.getNetworkHeaders();
|
|
String pollingRoute = this.genericDataManager.getPollingRoute();
|
|
Map activeUserDataForNetworkCall = this.userManager.getActiveUserDataForNetworkCall();
|
|
if (Utils.isEmpty(activeUserDataForNetworkCall) || Utils.isEmpty(networkHeaders) || Utils.isEmpty(pollingRoute)) {
|
|
HSLogger.d("ftchNotif", "Skipping notification count fetch. Invalid params for network call.");
|
|
return -1;
|
|
}
|
|
long pollerCursor = this.userManager.getPollerCursor();
|
|
if (pollerCursor != 0) {
|
|
activeUserDataForNetworkCall.put("cursor", String.valueOf(pollerCursor));
|
|
}
|
|
activeUserDataForNetworkCall.put("did", this.device.getDeviceId());
|
|
activeUserDataForNetworkCall.put("platform-id", this.persistentStorage.getPlatformId());
|
|
try {
|
|
HSResponse makeRequest = new AuthenticationFailureNetwork(new GETNetwork(this.httpTransport, pollingRoute)).makeRequest(new HSRequestData(networkHeaders, activeUserDataForNetworkCall));
|
|
JSONObject jSONObject = new JSONObject(makeRequest.getResponseString());
|
|
int optInt = jSONObject.optInt("uc", 0);
|
|
int optInt2 = jSONObject.optInt("bpi", 5000);
|
|
int optInt3 = jSONObject.optInt("mpi", MBridgeCommon.DEFAULT_LOAD_TIMEOUT);
|
|
boolean optBoolean = jSONObject.optBoolean("cp", false);
|
|
long optLong = jSONObject.optLong("c", 0L);
|
|
this.userManager.setPollingBaseInterval(optInt2);
|
|
this.userManager.setPollingMaxInterval(optInt3);
|
|
this.userManager.setShouldPollFlag(optBoolean);
|
|
if (optInt > 0) {
|
|
int unreadNotificationCount = this.userManager.getUnreadNotificationCount() + optInt;
|
|
this.userManager.updateUnreadCountBy(optInt);
|
|
if (!this.userManager.isPushTokenSynced()) {
|
|
this.notificationManager.showNotification(this.genericDataManager.getNotificationStringForCount(unreadNotificationCount), false);
|
|
}
|
|
}
|
|
this.userManager.setPollerCursor(optLong);
|
|
return makeRequest.getStatus();
|
|
} catch (HSRootApiException e) {
|
|
HSRootApiException.ExceptionType exceptionType = e.exceptionType;
|
|
if (exceptionType == NetworkException.INVALID_AUTH_TOKEN) {
|
|
this.hsEventProxy.sendAuthFailureEvent("invalid user auth token");
|
|
} else if (exceptionType == NetworkException.AUTH_TOKEN_NOT_PROVIDED) {
|
|
this.hsEventProxy.sendAuthFailureEvent("missing user auth token");
|
|
}
|
|
HSLogger.e("ftchNotif", "HSRootApiException in poller request", e);
|
|
return -1;
|
|
} catch (JSONException e2) {
|
|
HSLogger.e("ftchNotif", "Error parsing poller response", e2);
|
|
return -1;
|
|
} catch (Exception e3) {
|
|
HSLogger.e("ftchNotif", "Error in poller request", e3);
|
|
return -1;
|
|
}
|
|
}
|
|
}
|