得物.apk(点击下载) / a.java


package ze1;

import android.content.Context;
import bj1.e;
import com.liulishuo.okdownload.core.cause.EndCause;
import com.liulishuo.okdownload.core.cause.ResumeFailedCause;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.shizhuang.duapp.stream.constant.ErrorMsgConstant;
import com.shizhuang.duapp.stream.interfaces.IMediaSdk;
import com.shizhuang.duapp.stream.interfaces.ISdkInitListener;
import com.shizhuang.duapp.stream.util.ResourceHelper;
import fd.n;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import java.io.File;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/* compiled from: DuMediaSdk.kt */
public final class a implements IMediaSdk {
    public static ChangeQuickRedirect changeQuickRedirect;
    @Nullable

    /* renamed from: a  reason: collision with root package name */
    public ISdkInitListener f40688a;

    /* renamed from: ze1.a$a  reason: collision with other inner class name */
    /* compiled from: DuMediaSdk.kt */
    public static final class C0756a<T, R> implements Function<String, String> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ Context b;

        public C0756a(Context context) {
            this.b = context;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Function
        public String apply(String str) {
            PatchProxyResult proxy = PatchProxy.proxy(new Object[]{str}, this, changeQuickRedirect, false, 334664, new Class[]{String.class}, String.class);
            if (proxy.isSupported) {
                return (String) proxy.result;
            }
            File u4 = tl.a.u((String) n.c("community_module", "ModelResourceV2", String.class, "https://apk.poizon.com/duApp/Android_Config/resource/updatehair.zip"), null, null);
            ResourceHelper resourceHelper = ResourceHelper.f26082a;
            String f = resourceHelper.f(this.b, u4);
            return f != null ? f : resourceHelper.h(this.b, u4);
        }
    }

    /* compiled from: DuMediaSdk.kt */
    public static final class b<T> implements Consumer<String> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ a b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ Context f40689c;

        public b(a aVar, Context context) {
            this.b = aVar;
            this.f40689c = context;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Consumer
        public void accept(String str) {
            ISdkInitListener sdkInitListener;
            if (!PatchProxy.proxy(new Object[]{str}, this, changeQuickRedirect, false, 334665, new Class[]{String.class}, Void.TYPE).isSupported && nq.b.c(this.f40689c) && (sdkInitListener = this.b.getSdkInitListener()) != null) {
                sdkInitListener.onSuccess();
            }
        }
    }

    /* compiled from: DuMediaSdk.kt */
    public static final class c<T> implements Consumer<Throwable> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ a b;

        public c(a aVar) {
            this.b = aVar;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Consumer
        public void accept(Throwable th2) {
            ISdkInitListener sdkInitListener;
            if (!PatchProxy.proxy(new Object[]{th2}, this, changeQuickRedirect, false, 334666, new Class[]{Throwable.class}, Void.TYPE).isSupported && (sdkInitListener = this.b.getSdkInitListener()) != null) {
                sdkInitListener.onSuccess();
            }
        }
    }

    /* compiled from: PumpExtension.kt */
    public static final class d extends vl.a {
        public static ChangeQuickRedirect changeQuickRedirect;

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ a f40690a;
        public final /* synthetic */ Context b;

        public d(a aVar, Context context) {
            this.f40690a = aVar;
            this.b = context;
        }

        @Override // com.liulishuo.okdownload.core.listener.assist.Listener1Assist.Listener1Callback, vl.a
        public void connected(@NotNull s9.c cVar, int i, long j, long j12) {
            Object[] objArr = {cVar, new Integer(i), new Long(j), new Long(j12)};
            ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
            Class cls = Long.TYPE;
            if (!PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 334669, new Class[]{s9.c.class, Integer.TYPE, cls, cls}, Void.TYPE).isSupported) {
                super.connected(cVar, i, j, j12);
            }
        }

        @Override // vl.a
        public void onTaskEnd(@NotNull s9.c cVar, @NotNull EndCause endCause, @Nullable Exception exc) {
            if (!PatchProxy.proxy(new Object[]{cVar, endCause, exc}, this, changeQuickRedirect, false, 334670, new Class[]{s9.c.class, EndCause.class, Exception.class}, Void.TYPE).isSupported) {
                if (endCause == EndCause.COMPLETED) {
                    File i = cVar.i();
                    if (i != null) {
                        this.f40690a.b(this.b, i.getAbsolutePath());
                        return;
                    }
                    return;
                }
                ISdkInitListener sdkInitListener = this.f40690a.getSdkInitListener();
                if (sdkInitListener != null) {
                    ErrorMsgConstant errorMsgConstant = ErrorMsgConstant.ERROR_CV_LICENSE_DOWNLOAD_FAILED;
                    sdkInitListener.onFailed(errorMsgConstant.getCode(), errorMsgConstant.getMsg(), exc);
                }
            }
        }

        @Override // vl.a
        public void onTaskStart(@NotNull s9.c cVar) {
            boolean z = PatchProxy.proxy(new Object[]{cVar}, this, changeQuickRedirect, false, 334667, new Class[]{s9.c.class}, Void.TYPE).isSupported;
        }

        @Override // vl.a
        public void progress(@NotNull s9.c cVar, float f, long j, long j12) {
            Object[] objArr = {cVar, new Float(f), new Long(j), new Long(j12)};
            ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
            Class cls = Long.TYPE;
            if (!PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 334671, new Class[]{s9.c.class, Float.TYPE, cls, cls}, Void.TYPE).isSupported) {
                super.progress(cVar, f, j, j12);
            }
        }

        @Override // com.liulishuo.okdownload.core.listener.assist.Listener1Assist.Listener1Callback, vl.a
        public void retry(@NotNull s9.c cVar, @NotNull ResumeFailedCause resumeFailedCause) {
            if (!PatchProxy.proxy(new Object[]{cVar, resumeFailedCause}, this, changeQuickRedirect, false, 334668, new Class[]{s9.c.class, ResumeFailedCause.class}, Void.TYPE).isSupported) {
                super.retry(cVar, resumeFailedCause);
            }
        }
    }

    public final boolean a(String str) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{str}, this, changeQuickRedirect, false, 334659, new Class[]{String.class}, Boolean.TYPE);
        if (proxy.isSupported) {
            return ((Boolean) proxy.result).booleanValue();
        }
        File file = new File(str);
        if (file.exists() || file.mkdirs()) {
            return true;
        }
        return false;
    }

    public final void b(@NotNull Context context, @NotNull String str) {
        if (!PatchProxy.proxy(new Object[]{context, str}, this, changeQuickRedirect, false, 334662, new Class[]{Context.class, String.class}, Void.TYPE).isSupported) {
            e.just("resource").map(new C0756a(context)).subscribeOn(Schedulers.io()).observeOn(ej1.a.c()).subscribe(new b(this, context), new c(this));
        }
    }

    public final void c(@NotNull Context context) {
        if (!PatchProxy.proxy(new Object[]{context}, this, changeQuickRedirect, false, 334661, new Class[]{Context.class}, Void.TYPE).isSupported) {
            String str = (String) n.c("community_module", "community_cv_license_v2", String.class, "https://apk.poizon.com/duApp/Android_Config/license/cv/duapp_20210309_20210608_com.shizhuang.duapp_v1.0.2.licbag");
            File u4 = tl.a.u(str, null, null);
            if (u4 == null) {
                tl.a.r(str, null, null, new d(this, context));
            } else {
                b(context, u4.getAbsolutePath());
            }
        }
    }

    @Override // com.shizhuang.duapp.stream.interfaces.IMediaSdk
    @Nullable
    public ISdkInitListener getSdkInitListener() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 334656, new Class[0], ISdkInitListener.class);
        return proxy.isSupported ? (ISdkInitListener) proxy.result : this.f40688a;
    }

    /* JADX WARNING: Removed duplicated region for block: B:18:0x0077  */
    /* JADX WARNING: Removed duplicated region for block: B:22:? A[RETURN, SYNTHETIC] */
    @Override // com.shizhuang.duapp.stream.interfaces.IMediaSdk
    public void initSdk(@NotNull Context context) {
        Exception e;
        ISdkInitListener sdkInitListener;
        if (!PatchProxy.proxy(new Object[]{context}, this, changeQuickRedirect, false, 334658, new Class[]{Context.class}, Void.TYPE).isSupported) {
            try {
                String e6 = ResourceHelper.f26082a.e(context);
                try {
                    if (!a(e6)) {
                        ISdkInitListener sdkInitListener2 = getSdkInitListener();
                        if (sdkInitListener2 != null) {
                            ErrorMsgConstant errorMsgConstant = ErrorMsgConstant.ERROR_WORKSPACE_NOT_FOUND;
                            sdkInitListener2.onFailed(errorMsgConstant.getCode(), errorMsgConstant.getMsg(), null);
                            return;
                        }
                        return;
                    }
                    boolean z = PatchProxy.proxy(new Object[]{context, e6}, this, changeQuickRedirect, false, 334660, new Class[]{Context.class, String.class}, Void.TYPE).isSupported;
                    c(context);
                } catch (Exception e12) {
                    e = e12;
                    e.printStackTrace();
                    sdkInitListener = getSdkInitListener();
                    if (sdkInitListener == null) {
                    }
                }
            } catch (Exception e13) {
                e = e13;
                e.printStackTrace();
                sdkInitListener = getSdkInitListener();
                if (sdkInitListener == null) {
                    ErrorMsgConstant errorMsgConstant2 = ErrorMsgConstant.ERROR_INIT_SDK_FAILED;
                    sdkInitListener.onFailed(errorMsgConstant2.getCode(), errorMsgConstant2.getMsg(), e);
                }
            }
        }
    }

    @Override // com.shizhuang.duapp.stream.interfaces.IMediaSdk
    public void release() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 334663, new Class[0], Void.TYPE).isSupported) {
            setSdkInitListener(null);
        }
    }

    @Override // com.shizhuang.duapp.stream.interfaces.IMediaSdk
    public void setSdkInitListener(@Nullable ISdkInitListener iSdkInitListener) {
        if (!PatchProxy.proxy(new Object[]{iSdkInitListener}, this, changeQuickRedirect, false, 334657, new Class[]{ISdkInitListener.class}, Void.TYPE).isSupported) {
            this.f40688a = iSdkInitListener;
        }
    }
}