package com.seewo.ota.u;

import android.content.Context;
import android.os.SystemClock;
import android.util.Log;
import d.d.c.a.a;
import d.d.c.a.e;
import java.io.IOException;
import java.util.List;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;

/* JADX INFO: compiled from: UdiClient.java */
/* JADX INFO: loaded from: classes.dex */
public class a {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static volatile a f2273b;
    private OkHttpClient a;

    public static a a() {
        if (f2273b == null) {
            synchronized (a.class) {
                if (f2273b == null) {
                    f2273b = new a();
                }
            }
        }
        return f2273b;
    }

    public void b(Context context) {
        e.l(context, "xZLhYnkb0bDfRDjUAPlv6InMqiZy4IUKG7IUAo_0");
        if (this.a == null) {
            this.a = e.n().build();
            Log.i("UdiClient", "init: " + this.a.connectTimeoutMillis());
        }
    }

    public String c(String str) {
        if (this.a == null) {
            Log.d("UdiClient", "not init");
            return "";
        }
        try {
            ResponseBody responseBodyBody = this.a.newCall(new Request.Builder().url(e.k(str)).build()).execute().body();
            if (responseBodyBody == null) {
                return null;
            }
            String strString = responseBodyBody.string();
            Log.d("UdiClient", "rawGetRequest " + str + " " + strString);
            return strString;
        } catch (IOException e2) {
            Log.e("UdiClient", "", e2);
            return null;
        }
    }

    public boolean d(String str, String str2) {
        if (this.a == null) {
            Log.d("UdiClient", "not init");
            return false;
        }
        Log.d("UdiClient", "rawPostValue " + str + " " + str2);
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        try {
            Response responseExecute = this.a.newCall(new Request.Builder().url(e.k(str)).post(RequestBody.create(MediaType.parse("application/json;charset=utf-8"), str2)).build()).execute();
            Log.d("UdiClient", "rawPostValue end " + (SystemClock.elapsedRealtime() - jElapsedRealtime) + " " + responseExecute.code());
            return responseExecute.code() == 200;
        } catch (IOException e2) {
            Log.e("UdiClient", "", e2);
            return false;
        }
    }

    public void e(List<String> list, a.f fVar) {
        e.q(list, fVar);
    }

    public void f(List<String> list, a.f fVar) {
        e.s(list, fVar);
    }
}
