导航菜单

页面标题

页面副标题

OLX India v19.42.007 - a.java 源代码

正在查看: OLX India v19.42.007 应用的 a.java JAVA 源代码文件

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


package com.payu.payuanalytics.analytics.manager;

import android.content.Context;
import android.util.Log;
import com.payu.payuanalytics.analytics.model.BaseAnalytics;
import com.payu.payuanalytics.analytics.utils.PayUAnalyticsConstant;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.Thread;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.text.Charsets;
import kotlin.text.m;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public final class a {
    public final BaseAnalytics a;
    public final String b = Reflection.b(a.class).i();
    public final Context c;
    public final String d;
    public final String e;
    public volatile boolean f;
    public Timer g;
    public volatile boolean h;
    public boolean i;

    @Metadata
    public static final class C0087a extends TimerTask {
        public C0087a() {
        }

        @Override
        public void run() {
            a.this.k();
        }
    }

    public a(final Context context, BaseAnalytics baseAnalytics) {
        this.a = baseAnalytics;
        this.c = context;
        this.d = Intrinsics.j(baseAnalytics.getAnalyticsFileName(), baseAnalytics.getAnalyticsConfig().getInitiatorIdentifier());
        this.e = Intrinsics.j(PayUAnalyticsConstant.PA_ANALYTICS_BUFFER_KEY, baseAnalytics.getAnalyticsConfig().getInitiatorIdentifier());
        final Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public final void uncaughtException(Thread thread, Throwable th) {
                a.d(a.this, context, defaultUncaughtExceptionHandler, thread, th);
            }
        });
    }

    public static final void d(a aVar, Context context, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, Thread thread, Throwable th) {
        while (aVar.f) {
        }
        aVar.l();
        try {
            FileOutputStream openFileOutput = aVar.c.openFileOutput(aVar.d, 0);
            com.payu.payuanalytics.analytics.utils.a aVar2 = com.payu.payuanalytics.analytics.utils.a.a;
            String c = aVar2.c(aVar.c, aVar.d, aVar.e);
            if (c != null && c.length() > 0) {
                JSONArray jSONArray = new JSONArray();
                JSONArray jSONArray2 = new JSONArray(String.valueOf(aVar2.c(aVar.c, aVar.d, aVar.e)));
                int length = jSONArray2.length();
                int i = 0;
                while (i < length) {
                    int i2 = i + 1;
                    jSONArray.put(jSONArray.length(), jSONArray2.getJSONObject(i));
                    i = i2;
                }
                openFileOutput.write(jSONArray.toString().getBytes(Charsets.b));
                com.payu.payuanalytics.analytics.utils.a.a.a(context, aVar.d, aVar.e);
            }
            openFileOutput.close();
        } catch (IOException e) {
            Log.d(a.class.getSimpleName(), Intrinsics.j("init:IOException", e.getLocalizedMessage()));
        } catch (Exception e2) {
            Log.d(a.class.getSimpleName(), Intrinsics.j("init:Exception", e2.getLocalizedMessage()));
        }
        aVar.f = false;
        uncaughtExceptionHandler.uncaughtException(thread, th);
    }

    public static final void e(a aVar, String str) {
        while (aVar.f) {
        }
        aVar.l();
        try {
            try {
                try {
                    JSONObject jSONObject = new JSONObject(str);
                    String a = aVar.a(aVar.c, aVar.d, 0);
                    JSONArray jSONArray = m.B(a, "", true) ? new JSONArray() : new JSONArray(a);
                    Context context = aVar.c;
                    FileOutputStream openFileOutput = context == null ? null : context.openFileOutput(aVar.d, 0);
                    jSONArray.put(jSONArray.length(), jSONObject);
                    if (openFileOutput != null) {
                        openFileOutput.write(jSONArray.toString().getBytes(Charsets.b));
                    }
                    if (openFileOutput != null) {
                        openFileOutput.close();
                    }
                    aVar.f = false;
                } catch (IOException e) {
                    Log.d(a.class.getSimpleName(), Intrinsics.j("log:IOException", e.getLocalizedMessage()));
                    aVar.i(str);
                    aVar.f = false;
                    aVar.j();
                }
            } catch (JSONException e2) {
                Log.d(a.class.getSimpleName(), Intrinsics.j("log:JSONException", e2.getLocalizedMessage()));
                aVar.f = false;
                aVar.j();
            } catch (Exception e3) {
                Log.d(a.class.getSimpleName(), Intrinsics.j("log:Exception", e3.getLocalizedMessage()));
                aVar.f = false;
                aVar.j();
            }
            aVar.j();
        } catch (Throwable th) {
            aVar.f = false;
            aVar.j();
            throw th;
        }
    }

    public static final void h(a aVar, String str) {
        synchronized (aVar) {
            try {
                try {
                    Log.d(a.class.getSimpleName(), Intrinsics.j("if locked - ", str));
                    while (aVar.h) {
                    }
                    aVar.h = true;
                    com.payu.payuanalytics.analytics.utils.a aVar2 = com.payu.payuanalytics.analytics.utils.a.a;
                    String c = aVar2.c(aVar.c, aVar.d, aVar.e);
                    JSONArray jSONArray = (c == null || m.B(c, "", true)) ? new JSONArray() : new JSONArray(c);
                    jSONArray.put(new JSONObject(str));
                    Log.d(a.class.getSimpleName(), Intrinsics.j("saving in buffer - ", jSONArray));
                    aVar2.b(aVar.c, aVar.d, aVar.e, jSONArray.toString());
                } catch (Exception e) {
                    Log.d(a.class.getSimpleName(), Intrinsics.j("storeinbuffer:Exception", e.getLocalizedMessage()));
                }
                aVar.h = false;
            } catch (Throwable th) {
                aVar.h = false;
                throw th;
            }
        }
    }

    public final String a(Context context, String str, int i) {
        String str2 = "";
        try {
            FileInputStream fileInputStream = null;
            if (!new File(context == null ? null : context.getFilesDir(), str).exists() && context != null) {
                context.openFileOutput(str, i);
            }
            fileInputStream = context.openFileInput(str);
            if (fileInputStream != null) {
                while (true) {
                    int read = fileInputStream.read();
                    if (read == -1) {
                        break;
                    }
                    str2 = Intrinsics.j(str2, Character.valueOf((char) read));
                }
                fileInputStream.close();
            }
        } catch (FileNotFoundException e) {
            Log.d(a.class.getSimpleName(), Intrinsics.j("readFileInputStream:FileNotFoundException", e.getLocalizedMessage()));
        } catch (IOException e2) {
            Log.d(a.class.getSimpleName(), Intrinsics.j("readFileInputStream:IOException", e2.getLocalizedMessage()));
        } catch (Exception e3) {
            Log.d(a.class.getSimpleName(), Intrinsics.j("readFileInputStream:Exception", e3.getLocalizedMessage()));
        }
        return str2;
    }

    public final JSONArray b(JSONArray jSONArray, JSONArray jSONArray2) {
        FileOutputStream fileOutputStream = null;
        try {
            try {
                JSONArray jSONArray3 = new JSONArray(jSONArray.toString());
                int length = jSONArray2.length();
                for (int i = 0; i < length; i++) {
                    jSONArray3.put(jSONArray2.getJSONObject(i));
                }
                Context context = this.c;
                if (context != null) {
                    fileOutputStream = context.openFileOutput(this.d, 0);
                }
                if (fileOutputStream != null) {
                    fileOutputStream.write(jSONArray3.toString().getBytes(Charsets.b));
                    Context context2 = this.c;
                    if (context2 != null) {
                        com.payu.payuanalytics.analytics.utils.a.a.a(context2, this.d, this.e);
                    }
                }
                return jSONArray3;
            } catch (Exception e) {
                Log.d(a.class.getSimpleName(), Intrinsics.j("copyBufferToFile:Exception", e.getLocalizedMessage()));
                if (fileOutputStream != null) {
                    try {
                        fileOutputStream.close();
                    } catch (IOException e2) {
                        Log.d(a.class.getSimpleName(), Intrinsics.j("copyBufferToFile:IOException", e2.getLocalizedMessage()));
                    }
                }
                this.h = false;
                return jSONArray;
            }
        } finally {
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.close();
                } catch (IOException e3) {
                    Log.d(a.class.getSimpleName(), Intrinsics.j("copyBufferToFile:IOException", e3.getLocalizedMessage()));
                }
            }
            this.h = false;
        }
    }

    public final void c() {
        Timer timer = this.g;
        if (timer == null || this.i) {
            return;
        }
        timer.cancel();
        Timer timer2 = this.g;
        if (timer2 != null) {
            timer2.purge();
        }
        this.i = true;
    }

    public final void f(final String str) {
        if (this.f) {
            i(str);
        } else {
            Executors.newSingleThreadExecutor().submit(new Runnable() {
                @Override
                public final void run() {
                    a.e(a.this, str);
                }
            });
        }
    }

    public final void g() {
        this.f = false;
        String c = com.payu.payuanalytics.analytics.utils.a.a.c(this.c, this.d, this.e);
        if (c != null && c.length() > 1) {
            j();
        }
    }

    public final void i(final String str) {
        new Thread(new Runnable() {
            @Override
            public final void run() {
                a.h(a.this, str);
            }
        }).start();
    }

    public final void j() {
        c();
        Timer timer = new Timer();
        this.g = timer;
        this.i = false;
        try {
            timer.schedule(new C0087a(), this.a.getTimerDelay());
        } catch (Exception e) {
            Log.d(this.b, String.valueOf(e.getMessage()));
        }
    }

    public final void k() {
        throw new UnsupportedOperationException("Method not decompiled: com.payu.payuanalytics.analytics.manager.a.k():void");
    }

    public final synchronized void l() {
        do {
        } while (this.f);
        this.f = true;
    }
}