导航菜单

页面标题

页面副标题

RummyCircle v11000.89 - LocationCommunicationManager.java 源代码

正在查看: RummyCircle v11000.89 应用的 LocationCommunicationManager.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.games24x7.pglocation.communication;

import android.content.Context;
import android.util.Log;
import androidx.core.content.b;
import com.games24x7.nae.NativeAttributionModule.Constants;
import com.games24x7.pgeventbus.PGEventBus;
import com.games24x7.pgeventbus.event.EventInfo;
import com.games24x7.pgeventbus.event.PGEvent;
import com.games24x7.pgeventbus.interfaces.PGModuleInterface;
import com.games24x7.pgeventbus.model.ResponseData;
import com.games24x7.pglocation.LocationData;
import com.games24x7.pglocation.a;
import com.games24x7.pglocation.communication.CommunicationInterface;
import com.games24x7.pglocation.communication.events.CheckGPSEvent;
import com.games24x7.pglocation.communication.events.GetLastLocationEvent;
import com.games24x7.pglocation.communication.events.GetLatLongEvent;
import com.games24x7.pglocation.communication.events.GetStateNameEvent;
import com.games24x7.pglocation.communication.events.IsMockLocationEnabledEvent;
import com.games24x7.pglocation.communication.events.IsPreviousLocationAvailableEvent;
import com.games24x7.pglocation.communication.events.IsValidLocationEvent;
import com.games24x7.pglocation.communication.events.LastLocationPayload;
import com.games24x7.pglocation.communication.events.LocationFromServerEvent;
import com.games24x7.pglocation.communication.events.LocationPermissionResponseEvent;
import com.games24x7.pglocation.communication.events.LocationRequestPayload;
import com.games24x7.pglocation.communication.events.LocationResponsePayload;
import com.games24x7.pglocation.communication.events.RequestGPSEvent;
import com.games24x7.pglocation.communication.events.parsed.IsValidLocationEventData;
import com.games24x7.pglocation.f;
import com.games24x7.pglocation.util.LocationConstants;
import com.games24x7.pglocation.util.LocationUtils;
import com.google.gson.d;
import java.util.HashMap;
import java.util.UUID;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import org.greenrobot.eventbus.i;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONObject;

@Metadata
public final class LocationCommunicationManager implements PGModuleInterface, CommunicationInterface {
    private static boolean allowMockLocation;

    @NotNull
    private final String TAG;

    @NotNull
    private final Context context;

    @NotNull
    private final PGEventBus pgEventBus;

    @NotNull
    private f pgLocationManager;

    @NotNull
    public static final Companion Companion = new Companion(null);

    @NotNull
    private static final HashMap<String, PGEvent> eventMap = new HashMap<>();

    @NotNull
    private static String serverUrlToFetchAddress = "https://www.rummycircle.com/player/account/getStateFromGeoLoc";

    @NotNull
    private static String serverUrlToUpdateGeoLoc = "https://www.rummycircle.com/signup/setGeoState";
    private static long locationFetchInterval = 7200000;
    private static boolean fetchAddressFromServer = true;

    @NotNull
    private static String analyticsEventCallbackType = "rn_native_callback";

    @NotNull
    private static String analyticsEventCallbackName = "ANALYTICS_COMPLEX_EVENT";

    @Metadata
    public static final class Companion {
        private Companion() {
        }

        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public final boolean getAllowMockLocation() {
            return LocationCommunicationManager.allowMockLocation;
        }

        @NotNull
        public final String getAnalyticsEventCallbackName() {
            return LocationCommunicationManager.analyticsEventCallbackName;
        }

        @NotNull
        public final String getAnalyticsEventCallbackType() {
            return LocationCommunicationManager.analyticsEventCallbackType;
        }

        public final boolean getFetchAddressFromServer() {
            return LocationCommunicationManager.fetchAddressFromServer;
        }

        public final long getLocationFetchInterval() {
            return LocationCommunicationManager.locationFetchInterval;
        }

        @NotNull
        public final String getServerUrlToFetchAddress() {
            return LocationCommunicationManager.serverUrlToFetchAddress;
        }

        @NotNull
        public final String getServerUrlToUpdateGeoLoc() {
            return LocationCommunicationManager.serverUrlToUpdateGeoLoc;
        }

        public final void setAllowMockLocation(boolean z) {
            LocationCommunicationManager.allowMockLocation = z;
        }

        public final void setAnalyticsEventCallbackName(@NotNull String str) {
            Intrinsics.checkNotNullParameter(str, "<set-?>");
            LocationCommunicationManager.analyticsEventCallbackName = str;
        }

        public final void setAnalyticsEventCallbackType(@NotNull String str) {
            Intrinsics.checkNotNullParameter(str, "<set-?>");
            LocationCommunicationManager.analyticsEventCallbackType = str;
        }

        public final void setFetchAddressFromServer(boolean z) {
            LocationCommunicationManager.fetchAddressFromServer = z;
        }

        public final void setLocationFetchInterval(long j) {
            LocationCommunicationManager.locationFetchInterval = j;
        }

        public final void setServerUrlToFetchAddress(@NotNull String str) {
            Intrinsics.checkNotNullParameter(str, "<set-?>");
            LocationCommunicationManager.serverUrlToFetchAddress = str;
        }

        public final void setServerUrlToUpdateGeoLoc(@NotNull String str) {
            Intrinsics.checkNotNullParameter(str, "<set-?>");
            LocationCommunicationManager.serverUrlToUpdateGeoLoc = str;
        }
    }

    public LocationCommunicationManager(@NotNull Context context, @NotNull PGEventBus pgEventBus, @NotNull f pgLocationManager) {
        this(context, pgEventBus, null, null, null, 28, null);
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(pgEventBus, "pgEventBus");
        Intrinsics.checkNotNullParameter(pgLocationManager, "pgLocationManager");
        this.pgLocationManager = pgLocationManager;
    }

    private final PGEvent createLocationResponseEvent(LocationResponsePayload locationResponsePayload, PGEvent pGEvent) {
        String payload = new d().s(new ResponseData(locationResponsePayload.isSuccess(), locationResponsePayload.getResult(), locationResponsePayload.getErrorCode(), locationResponsePayload.getErrorCode()));
        Log.d(this.TAG, "createLocationResponseEvent::payload:: " + payload);
        EventInfo eventData = pGEvent.getEventData();
        Intrinsics.checkNotNullExpressionValue(payload, "payload");
        return new PGEvent(eventData, payload, pGEvent.getCallbackData()).convertToResponse();
    }

    private final boolean isLocationPermissionGranted() {
        return b.a(this.context, "android.permission.ACCESS_COARSE_LOCATION") == 0;
    }

    @Override
    public PGEvent convert(@NotNull PGEvent pgEvent) {
        Intrinsics.checkNotNullParameter(pgEvent, "pgEvent");
        String name = pgEvent.getEventData().getName();
        switch (name.hashCode()) {
            case -2085122404:
                if (name.equals("statename")) {
                    return GetStateNameEvent.Companion.parse(pgEvent);
                }
                return null;
            case -1939011772:
                if (name.equals("locationpermission")) {
                    return LocationPermissionResponseEvent.Companion.parse(pgEvent);
                }
                return null;
            case -1254380201:
                if (name.equals("IS_MOCK_LOCATION_ENABLED")) {
                    return IsMockLocationEnabledEvent.Companion.parse(pgEvent);
                }
                return null;
            case -1201274163:
                if (name.equals("gpssettings")) {
                    return RequestGPSEvent.Companion.parse(pgEvent);
                }
                return null;
            case -242180821:
                if (name.equals("IS_LAT_LONG_STATE_IN_PROGRESS")) {
                    return IsLatLongStateInProgressEvent.Companion.parse(pgEvent);
                }
                return null;
            case -47054614:
                if (name.equals("lastloc")) {
                    return GetLastLocationEvent.Companion.parse(pgEvent);
                }
                return null;
            case -46366565:
                if (name.equals("latlong")) {
                    return GetLatLongEvent.Companion.parse(pgEvent);
                }
                return null;
            case 485735250:
                if (name.equals("IS_PREVIOUS_LOCATION_AVAILABLE")) {
                    return IsPreviousLocationAvailableEvent.Companion.parse(pgEvent);
                }
                return null;
            case 798229486:
                if (name.equals("LOCATION_FROM_SERVER")) {
                    return LocationFromServerEvent.Companion.parse(pgEvent);
                }
                return null;
            case 834595949:
                if (name.equals("IS_VALID_LOCATION")) {
                    return IsValidLocationEvent.Companion.parse(pgEvent);
                }
                return null;
            case 2085414913:
                if (name.equals("isgpsenabled")) {
                    return CheckGPSEvent.Companion.parse(pgEvent);
                }
                return null;
            default:
                return null;
        }
    }

    @NotNull
    public final String generateRequestID() {
        String uuid = UUID.randomUUID().toString();
        Intrinsics.checkNotNullExpressionValue(uuid, "randomUUID().toString()");
        return uuid;
    }

    @Override
    @NotNull
    public String getType() {
        return "location";
    }

    @i
    @NotNull
    public final Object onCheckGPSEvent(@NotNull CheckGPSEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "onCheckGPSEvent");
        String requestID = generateRequestID();
        eventMap.put(requestID, event);
        f fVar = this.pgLocationManager;
        fVar.getClass();
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        return f.a(fVar, fVar.b.a(), requestID);
    }

    @i
    public final void onIsLatLongStateProgressEvent(@NotNull IsLatLongStateInProgressEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "isLatLongStateInProgressEvent");
        String generateRequestID = generateRequestID();
        eventMap.put(generateRequestID, event);
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("isLatLongToStateInProgress", LocationUtils.INSTANCE.isLatLongToStateInProgress());
        CommunicationInterface.DefaultImpls.sendResponseEvent$default(this, true, jSONObject.toString(), null, null, generateRequestID, 12, null);
    }

    @i
    public final void onIsMockLocationEnabledEvent(@NotNull IsMockLocationEnabledEvent event) {
        boolean z;
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "onIsMockLocationEnabledEvent");
        String generateRequestID = generateRequestID();
        eventMap.put(generateRequestID, event);
        f fVar = this.pgLocationManager;
        fVar.getClass();
        try {
            z = fVar.b.b(LocationUtils.INSTANCE.getLastInMemoryLocation());
        } catch (Exception unused) {
            Log.e("PGLocationManager", "onIsMockLocationEnabledRequest :: Last Known Location is null...");
            z = false;
        }
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("isMockLocationEnabled", z);
        CommunicationInterface.DefaultImpls.sendResponseEvent$default(this, true, jSONObject.toString(), null, null, generateRequestID, 12, null);
    }

    @i
    public final void onIsPreviousLocationAvailableEvent(@NotNull IsPreviousLocationAvailableEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "isPrevLocAvailable");
        String generateRequestID = generateRequestID();
        eventMap.put(generateRequestID, event);
        boolean c = this.pgLocationManager.b.c(Companion.getLocationFetchInterval());
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("isPreviousLocationAvailable", c);
        CommunicationInterface.DefaultImpls.sendResponseEvent$default(this, true, jSONObject.toString(), null, null, generateRequestID, 12, null);
    }

    @i
    public final void onIsValidLocationEvent(@NotNull IsValidLocationEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "onIsValidLocationEvent: " + new d().s(event));
        String requestID = generateRequestID();
        eventMap.put(requestID, event);
        f fVar = this.pgLocationManager;
        IsValidLocationEventData eventData = event.getParsedPayload();
        fVar.getClass();
        Intrinsics.checkNotNullParameter(eventData, "eventData");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        fVar.b.a(eventData, requestID);
    }

    @i
    @NotNull
    public final Object onLastLocEvent(@NotNull GetLastLocationEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "onLastLocEvent");
        String requestID = generateRequestID();
        eventMap.put(requestID, event);
        f fVar = this.pgLocationManager;
        LastLocationPayload payload = event.getLastLocationPayload();
        fVar.getClass();
        Intrinsics.checkNotNullParameter(payload, "payload");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        a aVar = fVar.b;
        aVar.getClass();
        Intrinsics.checkNotNullParameter(payload, "payload");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        if (aVar.b(payload.getLocationValidity())) {
            Log.d("LocationRequestHandler", "permission granted");
            return a.a(aVar, requestID, payload, "lastloc", 8);
        }
        Log.d("LocationRequestHandler", "Failed-PGLOCATION: Location Permission Not Granted");
        a.a(false, (Object) null, "LOCATION_PERMISSION_ERROR", "Failed-PGLOCATION: Location Permission Not Granted", requestID);
        return "Failed-PGLOCATION: Location Permission Not Granted";
    }

    @i
    @NotNull
    public final Object onLatLongEvent(@NotNull GetLatLongEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "onLatLongEvent");
        String requestID = generateRequestID();
        eventMap.put(requestID, event);
        f fVar = this.pgLocationManager;
        LastLocationPayload payload = event.getLatLongPayload();
        fVar.getClass();
        Intrinsics.checkNotNullParameter(payload, "payload");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        a aVar = fVar.b;
        aVar.getClass();
        Intrinsics.checkNotNullParameter(payload, "payload");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        if (aVar.b(0L)) {
            return a.a(aVar, requestID, payload, "latlong", 8);
        }
        a.a(false, (Object) null, "LOCATION_PERMISSION_ERROR", "Failed-PGLOCATION: Location Permission Not Granted", requestID);
        return "Failed-PGLOCATION: Location Permission Not Granted";
    }

    @i
    public final void onLocationFromServer(@NotNull LocationFromServerEvent event) {
        JSONObject optJSONObject;
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "LocationFromServer :: " + new d().s(event));
        String requestID = String.valueOf(event.getEventData().getMetaData());
        f fVar = this.pgLocationManager;
        String payload = event.getPayloadInfo();
        fVar.getClass();
        Intrinsics.checkNotNullParameter(payload, "payload");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        LocationUtils locationUtils = LocationUtils.INSTANCE;
        if (locationUtils.isNetworkSuccess(payload)) {
            locationUtils.setLatLongToStateInProgress(false);
            JSONArray optJSONArray = new JSONObject(payload).optJSONArray("result");
            String optString = new JSONObject((optJSONArray == null || (optJSONObject = optJSONArray.optJSONObject(0)) == null) ? null : optJSONObject.optString(Constants.SHARED_PREFS_RESPONSE)).optString("body");
            Log.d("PGLocationManager", "locationDataJsonStr:: " + optString);
            JSONObject jSONObject = new JSONObject(optString);
            LocationData locationData = new LocationData(null, jSONObject.optString("geoLocCity"), jSONObject.optString("geoLocState"), jSONObject.optString("geoLocCountry"), jSONObject.optString("geoLocPostalCode"), null, null, null, 225, null);
            Log.d("PGLocationManager", "locationDataJsonOBJ:: " + locationData);
            String string = fVar.c.getString("latitude", "");
            String string2 = fVar.c.getString("longitude", "");
            Log.d("PGLocationManager", "Latitude: " + string + " ; Longitude : " + string2);
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("latitude", string);
            jSONObject2.put("longitude", string2);
            jSONObject2.put("serialNumber", fVar.d);
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put("apiType", "POST");
            jSONObject3.put("contentType", Constants.CONTENT_TYPE);
            jSONObject3.put("url", Companion.getServerUrlToUpdateGeoLoc());
            jSONObject3.put("data", jSONObject2.toString());
            EventInfo eventInfo = new EventInfo("api", "network", null, null, 12, null);
            String jSONObject4 = jSONObject3.toString();
            Intrinsics.checkNotNullExpressionValue(jSONObject4, "apiCallPayload.toString()");
            PGEvent pGEvent = new PGEvent(eventInfo, jSONObject4, new EventInfo("na", "na", null, null, 12, null));
            Log.d("PGLocationManager", "start update location to server");
            new PGEventBus().postEvent(pGEvent);
            locationUtils.saveLocationData(fVar.c, locationData);
            CommunicationInterface communicationInterface = fVar.a;
            if (communicationInterface != null) {
                CommunicationInterface.DefaultImpls.sendResponseEvent$default(communicationInterface, true, locationData, null, null, requestID, 12, null);
            }
        } else {
            CommunicationInterface communicationInterface2 = fVar.a;
            if (communicationInterface2 != null) {
                CommunicationInterface.DefaultImpls.sendResponseEvent$default(communicationInterface2, false, null, "LOCATION_SERVER_ERROR", null, requestID, 8, null);
            }
            locationUtils.setLatLongToStateInProgress(false);
        }
        locationUtils.setLatLongToStateInProgress(false);
    }

    @i
    public final void onPermissionResponseEvent(@NotNull LocationPermissionResponseEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "onPermissionResponseEvent: " + new d().s(event));
        try {
            JSONObject jSONObject = new JSONObject(event.getPayloadInfo());
            EventInfo eventData = event.getEventData();
            String requestId = eventData.getRequestId();
            if (requestId == null) {
                requestId = "";
            }
            String str = requestId;
            eventData.getMetaData();
            JSONObject jSONObject2 = new JSONObject(jSONObject.getString("result"));
            Log.d(this.TAG, "status: " + jSONObject2.get("status"));
            if (Intrinsics.a(jSONObject2.get("status"), "GRANTED")) {
                Log.d(this.TAG, "onPermissionResponseEvent granted");
            } else {
                Log.d(this.TAG, "onPermissionResponseEvent not granted");
                sendResponseEvent(false, null, "LOCATION_PERMISSION_ERROR", "Failed-PGLOCATION: Location Permission Not Granted", str);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @i
    @NotNull
    public final Object onRequestGPSEvent(@NotNull RequestGPSEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "onRequestGPSEvent");
        String requestID = generateRequestID();
        eventMap.put(requestID, event);
        f fVar = this.pgLocationManager;
        LocationRequestPayload payload = event.getLocationRequestPayload();
        fVar.getClass();
        Intrinsics.checkNotNullParameter(payload, "payload");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        return fVar.b.a(payload, requestID);
    }

    @i
    @NotNull
    public final Object onStateNameEvent(@NotNull GetStateNameEvent event) {
        Intrinsics.checkNotNullParameter(event, "event");
        Log.d(this.TAG, "onStateNameEvent");
        String requestID = generateRequestID();
        eventMap.put(requestID, event);
        f fVar = this.pgLocationManager;
        LastLocationPayload payload = event.getStateNamePayload();
        fVar.getClass();
        Intrinsics.checkNotNullParameter(payload, "payload");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        a aVar = fVar.b;
        aVar.getClass();
        Intrinsics.checkNotNullParameter(payload, "payload");
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        if (aVar.b(0L)) {
            return a.a(aVar, requestID, payload, "statename", 8);
        }
        Log.d("LocationRequestHandler", "Failed-PGLOCATION: Location Permission Not Granted");
        a.a(false, (Object) null, "LOCATION_PERMISSION_ERROR", "Failed-PGLOCATION: Location Permission Not Granted", requestID);
        return "Failed-PGLOCATION: Location Permission Not Granted";
    }

    @Override
    public PGEvent processSyncRequest(@NotNull PGEvent pgEvent) {
        String str;
        StringBuilder sb;
        boolean z;
        Intrinsics.checkNotNullParameter(pgEvent, "pgEvent");
        Log.d(this.TAG, "processSyncRequest:: eventReceived:: " + pgEvent.getEventData().getName());
        String name = pgEvent.getEventData().getName();
        switch (name.hashCode()) {
            case -1254380201:
                if (name.equals("IS_MOCK_LOCATION_ENABLED")) {
                    try {
                        if ((pgEvent instanceof IsMockLocationEnabledEvent ? (IsMockLocationEnabledEvent) pgEvent : null) == null) {
                            Log.d(this.TAG, "event conversion fail:: returning null");
                            return null;
                        }
                        f fVar = this.pgLocationManager;
                        fVar.getClass();
                        try {
                            z = fVar.b.b(LocationUtils.INSTANCE.getLastInMemoryLocation());
                        } catch (Exception unused) {
                            Log.e("PGLocationManager", "onIsMockLocationEnabledRequest :: Last Known Location is null...");
                            z = false;
                        }
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("isMockLocationEnabled", z);
                        Unit unit = Unit.a;
                        return createLocationResponseEvent(new LocationResponsePayload(true, jSONObject.toString(), null, null, 12, null), pgEvent);
                    } catch (Exception e) {
                        e = e;
                        str = this.TAG;
                        sb = new StringBuilder("exception:: processSyncRequest:: ");
                        sb.append(e.getMessage());
                        Log.e(str, sb.toString());
                        e.printStackTrace();
                        return null;
                    }
                }
                return null;
            case -242180821:
                if (name.equals("IS_LAT_LONG_STATE_IN_PROGRESS")) {
                    try {
                        if ((pgEvent instanceof IsLatLongStateInProgressEvent ? (IsLatLongStateInProgressEvent) pgEvent : null) == null) {
                            Log.d(this.TAG, "event conversion fail:: returning null");
                            return null;
                        }
                        JSONObject jSONObject2 = new JSONObject();
                        jSONObject2.put("isLatLongToStateInProgress", LocationUtils.INSTANCE.isLatLongToStateInProgress());
                        Unit unit2 = Unit.a;
                        return createLocationResponseEvent(new LocationResponsePayload(true, jSONObject2.toString(), null, null, 12, null), pgEvent);
                    } catch (Exception e2) {
                        e = e2;
                        str = this.TAG;
                        sb = new StringBuilder("exception:: processSyncRequest:: ");
                        sb.append(e.getMessage());
                        Log.e(str, sb.toString());
                        e.printStackTrace();
                        return null;
                    }
                }
                return null;
            case 485735250:
                if (name.equals("IS_PREVIOUS_LOCATION_AVAILABLE")) {
                    try {
                        if ((pgEvent instanceof IsPreviousLocationAvailableEvent ? (IsPreviousLocationAvailableEvent) pgEvent : null) == null) {
                            Log.d(this.TAG, "event conversion fail:: returning null");
                            return null;
                        }
                        boolean c = this.pgLocationManager.b.c(Companion.getLocationFetchInterval());
                        JSONObject jSONObject3 = new JSONObject();
                        jSONObject3.put("isPreviousLocationAvailable", c);
                        Unit unit3 = Unit.a;
                        return createLocationResponseEvent(new LocationResponsePayload(true, jSONObject3.toString(), null, null, 12, null), pgEvent);
                    } catch (Exception e3) {
                        e = e3;
                        str = this.TAG;
                        sb = new StringBuilder("exception:: processSyncRequest:: ");
                        sb.append(e.getMessage());
                        Log.e(str, sb.toString());
                        e.printStackTrace();
                        return null;
                    }
                }
                return null;
            case 834595949:
                if (name.equals("IS_VALID_LOCATION")) {
                    try {
                        IsValidLocationEvent isValidLocationEvent = pgEvent instanceof IsValidLocationEvent ? (IsValidLocationEvent) pgEvent : null;
                        if (isValidLocationEvent == null) {
                            Log.d(this.TAG, "event conversion fail:: returning null");
                            return null;
                        }
                        f fVar2 = this.pgLocationManager;
                        IsValidLocationEventData eventData = isValidLocationEvent.getParsedPayload();
                        fVar2.getClass();
                        Intrinsics.checkNotNullParameter(eventData, "eventData");
                        Intrinsics.checkNotNullParameter("na", "requestID");
                        return createLocationResponseEvent(fVar2.b.a(eventData, "na"), pgEvent);
                    } catch (Exception e4) {
                        e = e4;
                        str = this.TAG;
                        sb = new StringBuilder("exception:: processSyncRequest:: ");
                        sb.append(e.getMessage());
                        Log.e(str, sb.toString());
                        e.printStackTrace();
                        return null;
                    }
                }
                return null;
            case 2085414913:
                if (name.equals("isgpsenabled")) {
                    try {
                        if ((pgEvent instanceof CheckGPSEvent ? (CheckGPSEvent) pgEvent : null) == null) {
                            Log.d(this.TAG, "event conversion fail:: returning null");
                            return null;
                        }
                        f fVar3 = this.pgLocationManager;
                        fVar3.getClass();
                        Intrinsics.checkNotNullParameter("na", "requestID");
                        LocationResponsePayload a = f.a(fVar3, fVar3.b.a(), "na");
                        Log.d(this.TAG, "ACTION_CHECKGPSENABLED:: res:: " + a);
                        return createLocationResponseEvent(a, pgEvent);
                    } catch (Exception e5) {
                        e = e5;
                        str = this.TAG;
                        sb = new StringBuilder("exception:: processSyncRequest:: ");
                        sb.append(e.getMessage());
                        Log.e(str, sb.toString());
                        e.printStackTrace();
                        return null;
                    }
                }
                return null;
            default:
                return null;
        }
    }

    public final void sendPermissionRequest(@NotNull String requestID, @NotNull String actionName) {
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        Intrinsics.checkNotNullParameter(actionName, "actionName");
        Log.d(this.TAG, "sendPermissionRequest");
        this.pgEventBus.postEvent(new PGEvent(new EventInfo("checkPermission", "permission", null, null, 12, null), "{\"permissionName\" : \"COARSE_LOCATION\"}", new EventInfo("locationpermission", getType(), actionName, requestID)));
    }

    @Override
    public void sendResponseEvent(boolean z, Object obj, String str, String str2, @NotNull String requestID) {
        EventInfo eventInfo;
        Intrinsics.checkNotNullParameter(requestID, "requestID");
        Log.d(this.TAG, String.valueOf(obj));
        HashMap<String, PGEvent> hashMap = eventMap;
        if (!hashMap.containsKey(requestID)) {
            Log.e(this.TAG, "request id not found");
            return;
        }
        PGEvent pGEvent = hashMap.get(requestID);
        String payload = new d().s(new ResponseData(z, obj, str, str2));
        if (pGEvent == null || (eventInfo = pGEvent.getEventData()) == null) {
            eventInfo = new EventInfo(null, null, null, null, 15, null);
        }
        Intrinsics.checkNotNullExpressionValue(payload, "payload");
        this.pgEventBus.postEvent(new PGEvent(eventInfo, payload, pGEvent != null ? pGEvent.getCallbackData() : null).convertToResponse());
        hashMap.remove(requestID);
    }

    public LocationCommunicationManager(@NotNull Context context, @NotNull PGEventBus pgEventBus, CommunicationInterface communicationInterface) {
        this(context, pgEventBus, null, null, null, 28, null);
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(pgEventBus, "pgEventBus");
        this.pgLocationManager = new f(context, communicationInterface);
    }

    public LocationCommunicationManager(@NotNull Context context, @NotNull PGEventBus pgEventBus, @NotNull String statusBarColor, @NotNull String directEventCallbackType, @NotNull String directEventCallbackName) {
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(pgEventBus, "pgEventBus");
        Intrinsics.checkNotNullParameter(statusBarColor, "statusBarColor");
        Intrinsics.checkNotNullParameter(directEventCallbackType, "directEventCallbackType");
        Intrinsics.checkNotNullParameter(directEventCallbackName, "directEventCallbackName");
        this.context = context;
        this.pgEventBus = pgEventBus;
        this.TAG = "LocationComManager";
        LocationConstants.INSTANCE.setCOLOR_STATUSBAR(statusBarColor);
        pgEventBus.register(this);
        this.pgLocationManager = new f(context, this);
        analyticsEventCallbackType = directEventCallbackType;
        analyticsEventCallbackName = directEventCallbackName;
    }

    public LocationCommunicationManager(Context context, PGEventBus pGEventBus, String str, String str2, String str3, int i, DefaultConstructorMarker defaultConstructorMarker) {
        this(context, pGEventBus, (i & 4) != 0 ? "#c91b12" : str, (i & 8) != 0 ? "rn_native_callback" : str2, (i & 16) != 0 ? "ANALYTICS_COMPLEX_EVENT" : str3);
    }
}