package ru2; import android.app.Activity; import android.app.Application; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; import at0.a; import com.google.android.gms.common.internal.ServiceSpecificExtraArgs; import com.google.gson.Gson; import com.huawei.hms.support.api.entity.common.CommonConstant; import com.meizu.cloud.pushsdk.notification.model.AdvanceSetting; import com.tencent.wcdb.database.SQLiteDatabase; import com.xingin.capa.lib.common.CapaStats; import com.xingin.utils.XYUtilsCenter; import com.xingin.utils.async.run.task.XYRunnable; import com.xingin.utils.core.c1; import com.xingin.utils.core.t; import com.xingin.xybridge.R$string; import com.xingin.xybridge.business.HybridEventData; import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ScheduledFuture; import kotlin.Unit; import kotlin.collections.CollectionsKt__CollectionsKt; import kotlin.collections.CollectionsKt__IterablesKt; import kotlin.collections.CollectionsKt___CollectionsKt; import kotlin.io.FilesKt__UtilsKt; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.Lambda; import kotlin.jvm.internal.Ref; import kotlin.text.StringsKt__StringsJVMKt; import t10.e1; import t10.v; import t10.z0; import w13.ab; import y10.a0; public final class d { /* renamed from: a */ public static final d f127247a = new d(); /* renamed from: b */ public static final vu2.c f127248b; /* renamed from: c */ public static boolean f127249c; /* renamed from: d */ public static Gson f127250d = new Gson(); /* renamed from: e */ public static HashMap<String, Boolean> f127251e = new HashMap<>(); /* renamed from: f */ public static final ArrayList<tu2.b> f127252f = new ArrayList<>(); /* renamed from: g */ public static ScheduledFuture<?> f127253g; /* renamed from: h */ public static String f127254h; public static final class a extends Lambda implements Function0<Unit> { /* renamed from: a */ public static final a f127255a = new a(); /* renamed from: ru2.d$a$a */ public static final class C2030a extends XYRunnable { public C2030a() { super("netChange", null, 2, null); } @Override // com.xingin.utils.async.run.task.XYRunnable public void execute() { d.f127247a.C(); d.f127253g = null; } } public static final class b extends XYRunnable { public b() { super("netChange", null, 2, null); } @Override // com.xingin.utils.async.run.task.XYRunnable public void execute() { d.f127247a.H(); d.f127253g = null; } } public a() { super(0); } @Override // kotlin.jvm.functions.Function0 public final void invoke() { ko2.e.a("DownloadBridge", "current is wifi=" + d.f127248b.c() + " allowDownloadInMobileNet=" + d.f127249c); if (!d.f127248b.c() || d.f127249c) { b02.c cVar = b02.c.f5924t; if ((cVar.I() && vt2.f.g().f("allow_download_resume_with_wifi", true)) || (cVar.G() && d.f127249c)) { ScheduledFuture scheduledFuture = d.f127253g; if (scheduledFuture != null) { scheduledFuture.cancel(false); } d dVar = d.f127247a; d.f127253g = mi2.a.l(new b(), 800); return; } return; } ScheduledFuture scheduledFuture2 = d.f127253g; if (scheduledFuture2 != null) { scheduledFuture2.cancel(false); } d dVar2 = d.f127247a; d.f127253g = mi2.a.l(new C2030a(), 800); } } public static final class b extends Lambda implements Function1<String, Unit> { /* renamed from: a */ public final /* synthetic */ tu2.e f127256a; /* renamed from: b */ public final /* synthetic */ boolean f127257b; /* renamed from: c */ public final /* synthetic */ Function1<String, Unit> f127258c; /* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public b(tu2.e eVar, boolean z14, Function1<? super String, Unit> function1) { super(1); this.f127256a = eVar; this.f127257b = z14; this.f127258c = function1; } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(String str) { invoke(str); return Unit.INSTANCE; } public final void invoke(String str) { Intrinsics.checkNotNullParameter(str, AdvanceSetting.NETWORK_TYPE); d.f127247a.r(this.f127256a, this.f127257b, this.f127258c); } } public static final class c extends Lambda implements Function1<String, Unit> { /* renamed from: a */ public final /* synthetic */ tu2.e f127259a; /* renamed from: b */ public final /* synthetic */ boolean f127260b; /* renamed from: c */ public final /* synthetic */ Function1<String, Unit> f127261c; /* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public c(tu2.e eVar, boolean z14, Function1<? super String, Unit> function1) { super(1); this.f127259a = eVar; this.f127260b = z14; this.f127261c = function1; } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(String str) { invoke(str); return Unit.INSTANCE; } public final void invoke(String str) { Intrinsics.checkNotNullParameter(str, AdvanceSetting.NETWORK_TYPE); d.f127247a.r(this.f127259a, this.f127260b, this.f127261c); } } /* renamed from: ru2.d$d */ public static final class C2031d extends Lambda implements Function0<Unit> { /* renamed from: a */ public final /* synthetic */ Function1<String, Unit> f127262a; /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public C2031d(Function1<? super String, Unit> function1) { super(0); this.f127262a = function1; } @Override // kotlin.jvm.functions.Function0 public final void invoke() { Function1<String, Unit> function1 = this.f127262a; if (function1 != null) { function1.invoke(com.alipay.sdk.util.e.f18310a); } } } public static final class e extends Lambda implements Function1<Boolean, Unit> { /* renamed from: a */ public final /* synthetic */ Function1<String, Unit> f127263a; /* renamed from: b */ public final /* synthetic */ tu2.e f127264b; /* renamed from: c */ public final /* synthetic */ boolean f127265c; /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public e(Function1<? super String, Unit> function1, tu2.e eVar, boolean z14) { super(1); this.f127263a = function1; this.f127264b = eVar; this.f127265c = z14; } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(Boolean bool) { invoke(bool.booleanValue()); return Unit.INSTANCE; } public final void invoke(boolean z14) { if (!z14) { al2.e.f(R$string.eae); Function1<String, Unit> function1 = this.f127263a; if (function1 != null) { function1.invoke(com.alipay.sdk.util.e.f18310a); return; } return; } d.f127247a.w(this.f127264b, this.f127265c, this.f127263a); } } public static final class f extends Lambda implements Function0<Unit> { /* renamed from: a */ public final /* synthetic */ Function0<Unit> f127266a; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public f(Function0<Unit> function0) { super(0); this.f127266a = function0; } @Override // kotlin.jvm.functions.Function0 public final void invoke() { Function0<Unit> function0 = this.f127266a; if (function0 != null) { function0.invoke(); } } } public static final class g extends Lambda implements Function0<Unit> { /* renamed from: a */ public final /* synthetic */ Function1<String, Unit> f127267a; /* renamed from: b */ public final /* synthetic */ String f127268b; /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public g(Function1<? super String, Unit> function1, String str) { super(0); this.f127267a = function1; this.f127268b = str; } @Override // kotlin.jvm.functions.Function0 public final void invoke() { Function1<String, Unit> function1 = this.f127267a; if (function1 != null) { function1.invoke(this.f127268b); } } } public static final class h extends XYRunnable { /* renamed from: a */ public final /* synthetic */ tu2.e f127269a; /* renamed from: b */ public final /* synthetic */ boolean f127270b; /* renamed from: c */ public final /* synthetic */ WeakReference<Function1<String, Unit>> f127271c; public static final class a implements zs0.c { /* renamed from: a */ public final /* synthetic */ String f127272a; /* renamed from: b */ public final /* synthetic */ tu2.e f127273b; /* renamed from: c */ public final /* synthetic */ List<String> f127274c; /* renamed from: d */ public final /* synthetic */ Ref.BooleanRef f127275d; /* renamed from: e */ public final /* synthetic */ boolean f127276e; public a(String str, tu2.e eVar, List<String> list, Ref.BooleanRef booleanRef, boolean z14) { this.f127272a = str; this.f127273b = eVar; this.f127274c = list; this.f127275d = booleanRef; this.f127276e = z14; } @Override // zs0.c public void onCancel() { d.f127251e.remove(this.f127272a); ko2.e.a("DownloadBridge", "downloadFile onCancel"); tu2.a aVar = new tu2.a(this.f127272a, com.alipay.sdk.util.e.f18310a, null, null, 12, null); synchronized (d.f127247a) { for (tu2.b bVar : d.f127252f) { bVar.onEvent(d.f127250d.toJson(new HybridEventData(aVar, 0, null, 6, null))); } Unit unit = Unit.INSTANCE; } d.M(d.f127247a, "download_cancel", this.f127272a, this.f127276e, false, null, 24, null); } @Override // zs0.c public void onError(String str) { ko2.e.a("DownloadBridge", "downloadFile onError, " + str); tu2.a aVar = new tu2.a(this.f127272a, com.alipay.sdk.util.e.f18310a, null, null, 12, null); synchronized (d.f127247a) { for (tu2.b bVar : d.f127252f) { bVar.onEvent(d.f127250d.toJson(new HybridEventData(aVar, 0, null, 6, null))); } Unit unit = Unit.INSTANCE; } d.M(d.f127247a, "download_error", this.f127272a, this.f127276e, false, str, 8, null); } @Override // zs0.c public void onFinished(String str) { Object obj = d.f127251e.get(this.f127272a); Boolean bool = Boolean.TRUE; if (Intrinsics.areEqual(obj, bool) && str != null) { d.f127247a.B(this.f127272a, new File(str)); } if (Intrinsics.areEqual(this.f127273b.getShowInAlbum(), bool) && str != null) { File file = new File(str); Context a14 = e30.c.a(); Intrinsics.checkNotNullExpressionValue(a14, "getAppContext()"); String name = file.getName(); Intrinsics.checkNotNullExpressionValue(name, "originFilePath.name"); vu2.a.a(file, a14, name, null); } List<String> list = this.f127274c; if (!(list == null || list.isEmpty()) && str != null) { File file2 = new File(str); if (file2.exists()) { Iterator<T> it3 = this.f127274c.iterator(); while (it3.hasNext()) { File file3 = new File((String) it3.next(), file2.getName()); if (!file3.exists()) { t.g(file2, file3); } } } } this.f127275d.element = true; d.f127251e.remove(this.f127272a); ko2.e.a("DownloadBridge", "downloadFile onFinished, " + str); tu2.a aVar = new tu2.a(this.f127272a, "finished", null, null, 12, null); synchronized (d.f127247a) { for (tu2.b bVar : d.f127252f) { bVar.onEvent(d.f127250d.toJson(new HybridEventData(aVar, 0, null, 6, null))); } Unit unit = Unit.INSTANCE; } d.M(d.f127247a, "download_finish", this.f127272a, this.f127276e, false, null, 24, null); } @Override // zs0.c public void onPause() { ko2.e.a("DownloadBridge", "downloadFile onPause"); tu2.a aVar = new tu2.a(this.f127272a, "paused", null, null, 12, null); synchronized (d.f127247a) { for (tu2.b bVar : d.f127252f) { bVar.onEvent(d.f127250d.toJson(new HybridEventData(aVar, 0, null, 6, null))); } Unit unit = Unit.INSTANCE; } } @Override // zs0.c public void onProgress(int i10) { } @Override // zs0.c public void onProgress(long j14, long j15) { tu2.a aVar = new tu2.a(this.f127272a, "inprogress", Long.valueOf(j14), Long.valueOf(j15)); synchronized (d.f127247a) { for (tu2.b bVar : d.f127252f) { bVar.onEvent(d.f127250d.toJson(new HybridEventData(aVar, 0, null, 6, null))); } Unit unit = Unit.INSTANCE; } } @Override // zs0.c public void onStart() { d.f127251e.put(this.f127272a, Boolean.valueOf(this.f127276e)); ko2.e.a("DownloadBridge", "downloadFile onStart"); tu2.a aVar = new tu2.a(this.f127272a, "inprogress", null, null, 12, null); synchronized (d.f127247a) { for (tu2.b bVar : d.f127252f) { bVar.onEvent(d.f127250d.toJson(new HybridEventData(aVar, 0, null, 6, null))); } Unit unit = Unit.INSTANCE; } d.M(d.f127247a, CapaStats.Pages.Action.CAPA_MUSIC_MUSIC_DOWNLOAD_START, this.f127272a, this.f127276e, false, null, 24, null); } @Override // zs0.c public void onWait() { ko2.e.a("DownloadBridge", "downloadFile onWait"); tu2.a aVar = new tu2.a(this.f127272a, "inprogress", null, null, 12, null); synchronized (d.f127247a) { for (tu2.b bVar : d.f127252f) { bVar.onEvent(d.f127250d.toJson(new HybridEventData(aVar, 0, null, 6, null))); } Unit unit = Unit.INSTANCE; } } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public h(tu2.e eVar, boolean z14, WeakReference<Function1<String, Unit>> weakReference) { super("DownBri", null, 2, null); this.f127269a = eVar; this.f127270b = z14; this.f127271c = weakReference; } @Override // com.xingin.utils.async.run.task.XYRunnable public void execute() { ArrayList arrayList; Application e14 = XYUtilsCenter.e(); Intrinsics.checkNotNullExpressionValue(e14, "getApp()"); String k14 = z0.k(e14, t10.l.EXTERNAL_XHS_DIR); List<String> usagePathList = this.f127269a.getUsagePathList(); String str = null; if (usagePathList != null) { ArrayList arrayList2 = new ArrayList(CollectionsKt__IterablesKt.collectionSizeOrDefault(usagePathList, 10)); Iterator<T> it3 = usagePathList.iterator(); while (it3.hasNext()) { Application e15 = XYUtilsCenter.e(); Intrinsics.checkNotNullExpressionValue(e15, "getApp()"); arrayList2.add(new File(z0.k(e15, t10.l.EXTERNAL_FILE_PRIVATE), "feResources/" + ((String) it3.next())).getAbsolutePath()); } arrayList = arrayList2; } else { arrayList = null; } if (!(arrayList == null || arrayList.isEmpty())) { Object obj = arrayList.get(0); Intrinsics.checkNotNullExpressionValue(obj, "downloadPaths[0]"); k14 = (String) obj; } String downloadUrl = this.f127269a.getDownloadUrl(); if (Intrinsics.areEqual(this.f127269a.getShowInAlbum(), Boolean.TRUE) && this.f127269a.getFileName() != null) { str = new File(k14, this.f127269a.getFileName()).getAbsolutePath(); } Ref.BooleanRef booleanRef = new Ref.BooleanRef(); boolean a14 = a.C0069a.a(a0.f156440a, this.f127269a.getDownloadUrl(), null, k14, new a(downloadUrl, this.f127269a, arrayList, booleanRef, this.f127270b), str, null, 32, null); ko2.e.a("DownloadBridge", "downloadFile download result = " + a14); if (a14) { d.f127251e.put(downloadUrl, Boolean.valueOf(this.f127270b)); Function1<String, Unit> function1 = this.f127271c.get(); if (function1 != null) { function1.invoke("inprogress"); } ko2.e.a("DownloadBridge", "start download, status = " + "inprogress" + ", url = " + downloadUrl); d.M(d.f127247a, "download", downloadUrl, this.f127270b, false, null, 24, null); } else if (booleanRef.element) { Function1<String, Unit> function12 = this.f127271c.get(); if (function12 != null) { function12.invoke("finished"); } } else { Function1<String, Unit> function13 = this.f127271c.get(); if (function13 != null) { function13.invoke(com.alipay.sdk.util.e.f18310a); } d.M(d.f127247a, "download", downloadUrl, this.f127270b, false, null, 16, null); } } } public static final class i extends Lambda implements Function1<fj2.a, Unit> { /* renamed from: a */ public final /* synthetic */ Function1<Boolean, Unit> f127277a; /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.Boolean, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public i(Function1<? super Boolean, Unit> function1) { super(1); this.f127277a = function1; } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(fj2.a aVar) { invoke(aVar); return Unit.INSTANCE; } public final void invoke(fj2.a aVar) { Function1<Boolean, Unit> function1 = this.f127277a; if (function1 != null) { boolean z14 = true; if (aVar == null || !aVar.e()) { z14 = false; } function1.invoke(Boolean.valueOf(z14)); } } } public static final class j extends Lambda implements Function0<Unit> { /* renamed from: a */ public static final j f127278a = new j(); public j() { super(0); } @Override // kotlin.jvm.functions.Function0 public final void invoke() { vt2.f.g().q("allow_download_resume_with_wifi", false); } } public static final class k extends Lambda implements Function0<Unit> { /* renamed from: a */ public static final k f127279a = new k(); public k() { super(0); } @Override // kotlin.jvm.functions.Function0 public final void invoke() { vt2.f.g().q("allow_download_resume_with_wifi", true); } } public static final class l extends Lambda implements Function1<ab.a, Unit> { /* renamed from: a */ public final /* synthetic */ String f127280a; /* renamed from: b */ public final /* synthetic */ String f127281b; /* renamed from: c */ public final /* synthetic */ boolean f127282c; /* renamed from: d */ public final /* synthetic */ boolean f127283d; /* renamed from: e */ public final /* synthetic */ String f127284e; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public l(String str, String str2, boolean z14, boolean z15, String str3) { super(1); this.f127280a = str; this.f127281b = str2; this.f127282c = z14; this.f127283d = z15; this.f127284e = str3; } public final void a(ab.a aVar) { Intrinsics.checkNotNullParameter(aVar, "$this$withHybridFetchFile"); aVar.u(404); aVar.v(1.0f); aVar.r(this.f127280a); aVar.x(this.f127281b); aVar.t(this.f127282c ? 1 : 0); aVar.w(this.f127283d ? 1 : 0); aVar.s(this.f127284e); } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(ab.a aVar) { a(aVar); return Unit.INSTANCE; } } public static final class m extends Lambda implements Function1<String, Unit> { /* renamed from: a */ public final /* synthetic */ String f127285a; /* renamed from: b */ public final /* synthetic */ Function1<String, Unit> f127286b; /* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public m(String str, Function1<? super String, Unit> function1) { super(1); this.f127285a = str; this.f127286b = function1; } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(String str) { invoke(str); return Unit.INSTANCE; } public final void invoke(String str) { Intrinsics.checkNotNullParameter(str, AdvanceSetting.NETWORK_TYPE); d.f127247a.I(this.f127285a, this.f127286b); } } public static final class n extends Lambda implements Function1<String, Unit> { /* renamed from: a */ public final /* synthetic */ String f127287a; /* renamed from: b */ public final /* synthetic */ Function1<String, Unit> f127288b; /* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public n(String str, Function1<? super String, Unit> function1) { super(1); this.f127287a = str; this.f127288b = function1; } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(String str) { invoke(str); return Unit.INSTANCE; } public final void invoke(String str) { Intrinsics.checkNotNullParameter(str, AdvanceSetting.NETWORK_TYPE); d.f127247a.I(this.f127287a, this.f127288b); } } public static final class o extends Lambda implements Function0<Unit> { /* renamed from: a */ public final /* synthetic */ Function1<String, Unit> f127289a; /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> */ /* JADX WARN: Multi-variable type inference failed */ /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public o(Function1<? super String, Unit> function1) { super(0); this.f127289a = function1; } @Override // kotlin.jvm.functions.Function0 public final void invoke() { Function1<String, Unit> function1 = this.f127289a; if (function1 != null) { function1.invoke(com.alipay.sdk.util.e.f18310a); } } } static { vu2.c cVar = new vu2.c(); f127248b = cVar; cVar.d(a.f127255a); } /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: ru2.d */ /* JADX WARN: Multi-variable type inference failed */ public static /* synthetic */ void G(d dVar, Activity activity, Function1 function1, int i10, Object obj) { if ((i10 & 1) != 0) { activity = null; } if ((i10 & 2) != 0) { function1 = null; } dVar.F(activity, function1); } public static final void K(Activity activity) { Intrinsics.checkNotNullParameter(activity, "$activity"); String string = activity.getString(R$string.eab); Intrinsics.checkNotNullExpressionValue(string, "activity.getString(R.str…dge_download_auto_resume)"); new kk2.e(activity, new kk2.d(0, string, null, CollectionsKt__CollectionsKt.listOf((Object[]) new kk2.b[]{kk2.b.f98569d.c(j.f127278a), new kk2.b(R$string.widgets_dialog_btn_ok, k.f127279a, 0, 4, null)}), 5, null)).show(); } public static /* synthetic */ void M(d dVar, String str, String str2, boolean z14, boolean z15, String str3, int i10, Object obj) { boolean z16 = (i10 & 4) != 0 ? false : z14; boolean z17 = (i10 & 8) != 0 ? true : z15; if ((i10 & 16) != 0) { str3 = null; } dVar.L(str, str2, z16, z17, str3); } public static final void N(String str, String str2, boolean z14, boolean z15, String str3) { Intrinsics.checkNotNullParameter(str, "$action"); Intrinsics.checkNotNullParameter(str2, "$url"); qe2.a.a().p4("hybrid_fetch_file").m3(new l(str, str2, z14, z15, str3)).b(); } public static final void t(Activity activity, Function0 function0, Function1 function1, String str) { Intrinsics.checkNotNullParameter(activity, "$context"); Intrinsics.checkNotNullParameter(str, "$url"); String string = activity.getString(R$string.eac); Intrinsics.checkNotNullExpressionValue(string, "context.getString(R.stri…_download_use_mobile_net)"); new kk2.e(activity, new kk2.d(0, string, null, CollectionsKt__CollectionsKt.listOf((Object[]) new kk2.b[]{kk2.b.f98569d.c(new f(function0)), new kk2.b(R$string.widgets_dialog_btn_ok, new g(function1, str), 0, 4, null)}), 5, null)).show(); } public final boolean A(String str) { Intrinsics.checkNotNullParameter(str, "url"); String a14 = at0.b.f5157a.a(str); Application e14 = XYUtilsCenter.e(); Intrinsics.checkNotNullExpressionValue(e14, "getApp()"); File file = new File(z0.k(e14, t10.l.EXTERNAL_XHS_DIR), a14); if (file.exists()) { return B(str, file); } return false; } public final boolean B(String str, File file) { Uri uri; boolean z14; try { if (v.fromExtension(FilesKt__UtilsKt.getExtension(file)) != v.APK) { if (!(StringsKt__StringsJVMKt.endsWith$default(str, ".apk", false, 2, null))) { Intent intent = new Intent(CommonConstant.ACTION.HWID_SCHEME_URL); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(SQLiteDatabase.CREATE_IF_NECESSARY); intent.addFlags(1); if (Build.VERSION.SDK_INT >= 24) { Application e14 = XYUtilsCenter.e(); uri = FileProvider.getUriForFile(e14, XYUtilsCenter.e().getPackageName() + ".provider", file); } else { uri = Uri.fromFile(file); } intent.setDataAndType(uri, String.valueOf(v.fromExtension(FilesKt__UtilsKt.getExtension(file)))); if (intent.resolveActivity(XYUtilsCenter.e().getPackageManager()) != null) { XYUtilsCenter.h().startActivity(intent); z14 = true; } else { z14 = false; } M(this, "open", str, false, z14, null, 20, null); return true; } } if (!vu2.j.f141691a.c(file)) { f127254h = file.getAbsolutePath(); } else { M(this, "open", str, false, false, null, 28, null); } } catch (Exception e15) { ko2.e.f("DownloadBridge", "openFile", e15); } return true; } public final void C() { ko2.e.a("DownloadBridge", "pause all"); for (Map.Entry<String, Boolean> entry : f127251e.entrySet()) { a0.f156440a.e(entry.getKey()); } } public final void D(String str, Function1<? super String, Unit> function1) { Intrinsics.checkNotNullParameter(str, "url"); List<dt0.d> b14 = a0.f156440a.b(str); if (!b14.isEmpty()) { dt0.d dVar = (dt0.d) CollectionsKt___CollectionsKt.first((List) b14); if (dVar.i() == bt0.e.COMPLETED.getValue()) { if (new File(dVar.a(), dVar.e()).exists()) { String x14 = x(dVar.i()); if (function1 != null) { function1.invoke(x14); return; } return; } } else if (f127251e.containsKey(str)) { String x15 = x(dVar.i()); if (function1 != null) { function1.invoke(x15); return; } return; } } if (function1 != null) { function1.invoke("none"); } } public final synchronized void E(tu2.b bVar) { Intrinsics.checkNotNullParameter(bVar, ServiceSpecificExtraArgs.CastExtraArgs.LISTENER); ArrayList<tu2.b> arrayList = f127252f; if (!arrayList.contains(bVar)) { arrayList.add(bVar); ko2.e.a("DownloadBridge", "registerDownloadListener, callback size = " + arrayList.size()); } } public final void F(Activity activity, Function1<? super Boolean, Unit> function1) { if (activity == null) { Context h10 = XYUtilsCenter.h(); activity = h10 instanceof Activity ? (Activity) h10 : null; if (activity == null) { return; } } e1.o(activity, CollectionsKt__CollectionsKt.arrayListOf("android.permission.WRITE_EXTERNAL_STORAGE"), 8, new i(function1)); } public final void H() { ko2.e.a("DownloadBridge", "resume all"); for (Map.Entry<String, Boolean> entry : f127251e.entrySet()) { a0.f156440a.f(entry.getKey()); } } public final void I(String str, Function1<? super String, Unit> function1) { if (f127251e.containsKey(str)) { a0.f156440a.f(str); if (function1 != null) { function1.invoke("inprogress"); } if (!f127251e.containsKey(str)) { f127251e.put(str, Boolean.FALSE); } } else if (function1 != null) { function1.invoke("none"); } } public final void J() { Context h10 = XYUtilsCenter.h(); Activity activity = h10 instanceof Activity ? (Activity) h10 : null; if (activity != null) { c1.c(new a(activity)); } } public final void L(String str, String str2, boolean z14, boolean z15, String str3) { Intrinsics.checkNotNullParameter(str, "action"); Intrinsics.checkNotNullParameter(str2, "url"); we2.d.c(new c(str, str2, z14, z15, str3)); } public final synchronized void O(tu2.b bVar) { Intrinsics.checkNotNullParameter(bVar, ServiceSpecificExtraArgs.CastExtraArgs.LISTENER); ArrayList<tu2.b> arrayList = f127252f; if (arrayList.contains(bVar)) { arrayList.remove(bVar); ko2.e.a("DownloadBridge", "unregisterDownloadListener, callback size = " + arrayList.size()); } } public final void P(String str, String str2, Function1<? super String, Unit> function1) { Intrinsics.checkNotNullParameter(str, "url"); Intrinsics.checkNotNullParameter(str2, "action"); if (Intrinsics.areEqual(str2, "pause")) { a0.f156440a.e(str); if (function1 != null) { function1.invoke("paused"); } if (f127248b.c() && !vt2.f.g().f("allow_download_resume_with_wifi", false) && (!f127251e.isEmpty())) { J(); } } else if (Intrinsics.areEqual(str2, "resume")) { Activity activity = null; if (!v()) { G(this, null, null, 3, null); if (function1 != null) { function1.invoke(com.alipay.sdk.util.e.f18310a); } } else if (!y()) { Context h10 = XYUtilsCenter.h(); if (h10 instanceof Activity) { activity = (Activity) h10; } if (activity != null) { f127247a.s(activity, str, new m(str, function1), new n(str, function1), new o(function1)); } } else if (function1 != null) { function1.invoke(com.alipay.sdk.util.e.f18310a); } } } public final void q(tu2.e eVar, boolean z14, Function1<? super String, Unit> function1) { Intrinsics.checkNotNullParameter(eVar, "fetchFileEntity"); String downloadUrl = eVar.getDownloadUrl(); a0 a0Var = a0.f156440a; List<dt0.d> b14 = a0Var.b(downloadUrl); if (!b14.isEmpty()) { dt0.d dVar = (dt0.d) CollectionsKt___CollectionsKt.first((List) b14); if (dVar.i() == bt0.e.COMPLETED.getValue()) { if (new File(dVar.a(), dVar.e()).exists()) { String x14 = x(dVar.i()); if (function1 != null) { function1.invoke(x14); return; } return; } } else if (!f127251e.containsKey(downloadUrl) || dVar.i() == bt0.e.CANCELLED.getValue() || dVar.i() == bt0.e.FAILED.getValue()) { a0Var.a(downloadUrl); } else { String x15 = x(dVar.i()); if (function1 != null) { function1.invoke(x15); return; } return; } } Context h10 = XYUtilsCenter.h(); Activity activity = h10 instanceof Activity ? (Activity) h10 : null; if (activity != null) { s(activity, downloadUrl, new b(eVar, z14, function1), new c(eVar, z14, function1), new C2031d(function1)); } else if (function1 != null) { function1.invoke(com.alipay.sdk.util.e.f18310a); } } public final void r(tu2.e eVar, boolean z14, Function1<? super String, Unit> function1) { u(new e(function1, eVar, z14)); } public final boolean s(Activity activity, String str, Function1<? super String, Unit> function1, Function1<? super String, Unit> function12, Function0<Unit> function0) { if (y()) { return false; } b02.c cVar = b02.c.f5924t; if (cVar.I() || (cVar.G() && f127249c)) { function1.invoke(str); return true; } c1.c(new b(activity, function0, function12, str)); return false; } public final void u(Function1<? super Boolean, Unit> function1) { Context h10 = XYUtilsCenter.h(); Activity activity = h10 instanceof Activity ? (Activity) h10 : null; if (activity == null) { function1.invoke(Boolean.FALSE); return; } if (!(ContextCompat.checkSelfPermission(activity, "android.permission.WRITE_EXTERNAL_STORAGE") == 0)) { F(activity, function1); } else { function1.invoke(Boolean.TRUE); } } public final boolean v() { Context h10 = XYUtilsCenter.h(); Activity activity = h10 instanceof Activity ? (Activity) h10 : null; if (activity != null && ContextCompat.checkSelfPermission(activity, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) { return true; } return false; } public final void w(tu2.e eVar, boolean z14, Function1<? super String, Unit> function1) { mi2.a.n(new h(eVar, z14, new WeakReference(function1))); } public final String x(int i10) { if (i10 != bt0.e.QUEUED.getValue()) { if (i10 == bt0.e.START.getValue() || i10 == bt0.e.PROGRESS.getValue()) { return "inprogress"; } if (i10 == bt0.e.PAUSED.getValue()) { return "paused"; } if (i10 == bt0.e.COMPLETED.getValue()) { return "finished"; } if (i10 != bt0.e.CANCELLED.getValue()) { if (i10 == bt0.e.FAILED.getValue()) { return com.alipay.sdk.util.e.f18310a; } if (i10 == bt0.e.CONNECTED.getValue()) { return "inprogress"; } } } return "none"; } public final boolean y() { b02.c cVar = b02.c.f5924t; if (cVar.C() && cVar.D()) { return false; } al2.e.f(R$string.eaf); return true; } public final void z(boolean z14) { String str; if (z14 && (str = f127254h) != null) { vu2.j.f141691a.c(new File(str)); } f127254h = null; } }