- 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
106 lines
4.9 KiB
Java
106 lines
4.9 KiB
Java
package com.helpshift.notification;
|
|
|
|
import com.helpshift.chat.HSEventProxy;
|
|
import com.helpshift.concurrency.HSThreadingService;
|
|
import com.helpshift.log.HSLogger;
|
|
import com.helpshift.network.AuthenticationFailureNetwork;
|
|
import com.helpshift.network.HSNetwork;
|
|
import com.helpshift.network.HSRequestData;
|
|
import com.helpshift.network.HSResponse;
|
|
import com.helpshift.network.HTTPTransport;
|
|
import com.helpshift.network.POSTNetwork;
|
|
import com.helpshift.network.exception.HSRootApiException;
|
|
import com.helpshift.network.exception.NetworkException;
|
|
import com.helpshift.platform.Device;
|
|
import com.helpshift.storage.HSGenericDataManager;
|
|
import com.helpshift.storage.HSPersistentStorage;
|
|
import com.helpshift.util.Utils;
|
|
import com.helpshift.util.ValueListener;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class HSPushTokenManager {
|
|
public Device device;
|
|
public HSGenericDataManager genericDataManager;
|
|
public HSEventProxy hsEventProxy;
|
|
public HSThreadingService hsThreadingService;
|
|
public HTTPTransport httpTransport;
|
|
public HSPersistentStorage persistentStorage;
|
|
|
|
public HSPushTokenManager(Device device, HSPersistentStorage hSPersistentStorage, HSThreadingService hSThreadingService, HSEventProxy hSEventProxy, HTTPTransport hTTPTransport, HSGenericDataManager hSGenericDataManager) {
|
|
this.device = device;
|
|
this.persistentStorage = hSPersistentStorage;
|
|
this.hsThreadingService = hSThreadingService;
|
|
this.hsEventProxy = hSEventProxy;
|
|
this.httpTransport = hTTPTransport;
|
|
this.genericDataManager = hSGenericDataManager;
|
|
}
|
|
|
|
public void savePushToken(String str) {
|
|
this.persistentStorage.setCurrentPushToken(str);
|
|
}
|
|
|
|
public void registerPushTokenWithBackend(String str, Map map, ValueListener valueListener) {
|
|
pushTokenRequest(str, map, false, valueListener);
|
|
}
|
|
|
|
public void deregisterPushTokenForUser(Map map, ValueListener valueListener) {
|
|
pushTokenRequest("unreg", map, true, valueListener);
|
|
}
|
|
|
|
public final void pushTokenRequest(String str, Map map, boolean z, ValueListener valueListener) {
|
|
if (!this.device.isOnline() || Utils.isEmpty(str) || Utils.isEmpty(map)) {
|
|
HSLogger.e("pshTknManagr", "Error in syncing push token, preconditions failed.");
|
|
return;
|
|
}
|
|
Map networkHeaders = this.genericDataManager.getNetworkHeaders();
|
|
String pushTokenSyncRoute = this.genericDataManager.getPushTokenSyncRoute();
|
|
String platformId = this.persistentStorage.getPlatformId();
|
|
String deviceId = this.device.getDeviceId();
|
|
if (Utils.isEmpty(networkHeaders) || Utils.isEmpty(pushTokenSyncRoute) || Utils.isEmpty(platformId) || Utils.isEmpty(deviceId)) {
|
|
HSLogger.e("pshTknManagr", "Error in reading network header and route data");
|
|
return;
|
|
}
|
|
try {
|
|
map.put("token", str);
|
|
map.put("did", deviceId);
|
|
map.put("platform-id", platformId);
|
|
makePushTokenRequest(new AuthenticationFailureNetwork(new POSTNetwork(this.httpTransport, pushTokenSyncRoute)), new HSRequestData(networkHeaders, map), z, valueListener);
|
|
} catch (Exception e) {
|
|
HSLogger.e("pshTknManagr", "Error in syncing push token", e);
|
|
}
|
|
}
|
|
|
|
public final void makePushTokenRequest(final HSNetwork hSNetwork, final HSRequestData hSRequestData, final boolean z, final ValueListener valueListener) {
|
|
this.hsThreadingService.getNetworkService().submit(new Runnable() { // from class: com.helpshift.notification.HSPushTokenManager.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
try {
|
|
HSResponse makeRequest = hSNetwork.makeRequest(hSRequestData);
|
|
if (z) {
|
|
return;
|
|
}
|
|
int status = makeRequest.getStatus();
|
|
valueListener.update(Boolean.valueOf(status >= 200 && status < 300));
|
|
} catch (HSRootApiException e) {
|
|
if (!z) {
|
|
valueListener.update(Boolean.FALSE);
|
|
HSRootApiException.ExceptionType exceptionType = e.exceptionType;
|
|
if (exceptionType == NetworkException.INVALID_AUTH_TOKEN) {
|
|
HSPushTokenManager.this.hsEventProxy.sendAuthFailureEvent("invalid user auth token");
|
|
return;
|
|
} else {
|
|
if (exceptionType == NetworkException.AUTH_TOKEN_NOT_PROVIDED) {
|
|
HSPushTokenManager.this.hsEventProxy.sendAuthFailureEvent("missing user auth token");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
HSLogger.e("pshTknManagr", "Network error for deregister push token request", e);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|