导航菜单

页面标题

页面副标题

Oolka v2.4.42 - MixPanelIntentService.java 源代码

正在查看: Oolka v2.4.42 应用的 MixPanelIntentService.java JAVA 源代码文件

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


package co.hyperverge.hypersnapsdk.analytics.mixpanel.network;

import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import co.hyperverge.hypersnapsdk.data.remote.ApiClient;
import co.hyperverge.hypersnapsdk.helpers.NetworkHelper;
import co.hyperverge.hypersnapsdk.helpers.SDKInternalConfig;
import co.hyperverge.hypersnapsdk.utils.Utils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
import retrofit2.w;

@Deprecated
public class MixPanelIntentService extends JobIntentService {
    private static final String ARG_EVENTS = "events";
    private static final int MIX_PANEL_JOB_ID = 328;
    private static final String TAG = "MixPanelIntentService";
    private static EventSyncRepo eventSyncRepo = null;
    private static boolean isEnqueueingOldEvents = false;
    private List<MixPanelEvent> currentEvents;
    private MixPanelApiInterface mixPanelApiClient;

    public static void enqueueEvent(Context context, String str, JSONObject jSONObject) {
        StringBuilder sb = new StringBuilder();
        sb.append("enqueueEvent() called with: eventName = [");
        sb.append(str);
        sb.append("], props = [");
        sb.append(jSONObject.toString());
        sb.append("]");
        try {
            EventSyncRepo eventSyncRepo2 = getEventSyncRepo(context);
            MixPanelEvent mixPanelEvent = new MixPanelEvent(str, (Map) new Gson().fromJson(jSONObject.toString(), new TypeToken<HashMap<String, Object>>() {
            }.getType()));
            if (!eventSyncRepo2.addEvent(mixPanelEvent)) {
                StringBuilder sb2 = new StringBuilder();
                sb2.append("enqueueEvent: error adding event: [");
                sb2.append(mixPanelEvent.toString());
                sb2.append("] to eventQueue");
            }
            enqueuePendingEvents(context);
        } catch (IOException e) {
            StringBuilder sb3 = new StringBuilder();
            sb3.append("enqueueEvent: failed to create eventSyncRepo ");
            sb3.append(e.getLocalizedMessage());
        }
    }

    public static void enqueuePendingEvents(Context context) {
        int i;
        try {
            EventSyncRepo eventSyncRepo2 = getEventSyncRepo(context);
            StringBuilder sb = new StringBuilder();
            sb.append("enqueuePendingEvents: pending events in queue: ");
            sb.append(eventSyncRepo2.getEventsCount());
            if (eventSyncRepo2.hasPendingEvents() && NetworkHelper.isNetworkAvailable(context) && !isEnqueueingOldEvents) {
                try {
                    ArrayList arrayList = new ArrayList(eventSyncRepo2.getEventsList());
                    int size = arrayList.size();
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append("enqueuePendingEvents: size: ");
                    sb2.append(size);
                    sb2.append(", thread - ");
                    sb2.append(Thread.currentThread().getName());
                    int i2 = 0;
                    i = 0;
                    while (i2 < size) {
                        try {
                            int min = Math.min(size - i2, 50);
                            isEnqueueingOldEvents = true;
                            int i3 = i2 + min;
                            JobIntentService.enqueueWork(context, MixPanelIntentService.class, MIX_PANEL_JOB_ID, eventsToIntent(context, arrayList.subList(i2, i3)));
                            eventSyncRepo2.removeEvents(min);
                            i += min;
                            i2 = i3;
                        } catch (IOException e) {
                            e = e;
                            Utils.getErrorMessage(e);
                            if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
                                SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
                            }
                            StringBuilder sb3 = new StringBuilder();
                            sb3.append("enqueuePendingEvents: enqueued ");
                            sb3.append(i);
                            sb3.append(" events");
                            isEnqueueingOldEvents = false;
                        }
                    }
                } catch (IOException e2) {
                    e = e2;
                    i = 0;
                }
                StringBuilder sb32 = new StringBuilder();
                sb32.append("enqueuePendingEvents: enqueued ");
                sb32.append(i);
                sb32.append(" events");
                isEnqueueingOldEvents = false;
            }
        } catch (IOException e3) {
            StringBuilder sb4 = new StringBuilder();
            sb4.append("enqueuePendingEvents: failed to create eventSyncRepo ");
            sb4.append(e3.getLocalizedMessage());
        }
    }

    private static Intent eventsToIntent(Context context, List<MixPanelEvent> list) {
        StringBuilder sb = new StringBuilder();
        sb.append("eventToIntent() called with: events = [");
        sb.append(list);
        sb.append("]");
        Gson gson = new Gson();
        Intent intent = new Intent(context, (Class<?>) MixPanelIntentService.class);
        intent.putExtra("events", gson.toJson(list));
        return intent;
    }

    @NonNull
    private static EventSyncRepo getEventSyncRepo(Context context) throws IOException {
        if (eventSyncRepo == null) {
            eventSyncRepo = new EventSyncRepo(context);
        }
        return eventSyncRepo;
    }

    private w<Object> postEvents(String str) {
        StringBuilder sb = new StringBuilder();
        sb.append("postEvents() called with: requestString = [");
        sb.append(str);
        sb.append("]");
        try {
            return this.mixPanelApiClient.postEvents(str).execute();
        } catch (IOException unused) {
            if (eventSyncRepo.addEvents(this.currentEvents)) {
                return null;
            }
            StringBuilder sb2 = new StringBuilder();
            sb2.append("postEvents: Error adding events to file: ");
            sb2.append(this.currentEvents.size());
            return null;
        }
    }

    public void onDestroy() {
        List<MixPanelEvent> list;
        super.onDestroy();
        EventSyncRepo eventSyncRepo2 = eventSyncRepo;
        if (eventSyncRepo2 != null && (list = this.currentEvents) != null) {
            eventSyncRepo2.addEvents(list);
        }
        eventSyncRepo = null;
    }

    public void onHandleWork(@NonNull Intent intent) {
        StringBuilder sb = new StringBuilder();
        sb.append("onHandleWork() called with: intent = [");
        sb.append(intent);
        sb.append("]");
        if (this.mixPanelApiClient == null) {
            this.mixPanelApiClient = ApiClient.getMixPanelService();
        }
        try {
            Gson gson = new Gson();
            this.currentEvents = (List) gson.fromJson(intent.getStringExtra("events"), new TypeToken<List<MixPanelEvent>>() {
            }.getType());
            StringBuilder sb2 = new StringBuilder();
            sb2.append("onHandleWork() : posting mixPanelEvents = [");
            sb2.append(this.currentEvents);
            sb2.append("]");
            w<Object> postEvents = postEvents(gson.toJson(this.currentEvents));
            this.currentEvents = null;
            StringBuilder sb3 = new StringBuilder();
            sb3.append("onHandleWork() response = [");
            sb3.append(postEvents);
            sb3.append("]");
            if (postEvents == null) {
                return;
            }
            Object a = postEvents.a();
            if (a instanceof Double) {
                if (((Double) a).doubleValue() == 0.0d) {
                    return;
                }
                ((Double) a).doubleValue();
            } else if (a != null) {
                MixPanelErrorResponse mixPanelErrorResponse = (MixPanelErrorResponse) gson.fromJson(a.toString(), MixPanelErrorResponse.class);
                StringBuilder sb4 = new StringBuilder();
                sb4.append("onResponse: errorResponse: ");
                sb4.append(mixPanelErrorResponse);
            }
        } catch (Exception unused) {
        }
    }
}