package com.sigmob.sdk.base.services; import android.app.DownloadManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.widget.Toast; import com.czhj.sdk.common.ClientMetadata; import com.czhj.sdk.common.utils.FileUtil; import com.czhj.sdk.logger.SigmobLog; import com.sigmob.sdk.base.common.BaseBroadcastReceiver; import com.sigmob.sdk.base.common.a; import com.sigmob.sdk.base.common.d; import com.sigmob.sdk.base.common.l; import com.sigmob.sdk.base.common.x; import com.sigmob.sdk.base.models.BaseAdUnit; import com.sigmob.sdk.base.models.IntentActions; import com.sigmob.sdk.base.mta.PointCategory; import com.sigmob.sdk.base.network.e; import com.sigmob.sdk.base.utils.b; import com.sigmob.windad.WindAdError; import java.io.File; import java.util.HashMap; import java.util.Map; class c extends BroadcastReceiver { c() { } private void a(Context context, long j, BaseAdUnit baseAdUnit) { if (baseAdUnit != null) { Map<String, Object> a = l.a(a(context), j); e.a(baseAdUnit, a.AD_DOWNLOAD_FINISH); String str = "download info is null"; if (a != null) { String str2 = (String) a.get("fileName"); int intValue = ((Integer) a.get("status")).intValue(); int intValue2 = ((Integer) a.get("reason")).intValue(); Uri uri = (Uri) a.get("uri"); if (str2 == null || intValue != 8) { try { str = String.format("status %d, reason %d", Integer.valueOf(intValue), Integer.valueOf(intValue2)); boolean deleteFile = FileUtil.deleteFile(FileUtil.getRealFilePath(context, uri)); SigmobLog.i("handleDownloadComplete:fail:" + deleteFile); } catch (Throwable th) { SigmobLog.e(th.getMessage()); } } else { try { String realFilePath = FileUtil.getRealFilePath(context, uri); l.a(context, realFilePath, baseAdUnit); x.a(baseAdUnit, PointCategory.DOWNLOAD_END, ClientMetadata.getPackageInfoWithUri(context, realFilePath), "1"); HashMap hashMap = new HashMap(); hashMap.put("result", "1"); hashMap.put("downloadId", Long.valueOf(j)); BaseBroadcastReceiver.a(context, baseAdUnit.getUuid(), hashMap, IntentActions.ACTION_INTERSTITIAL_DOWNLOAD_END); return; } catch (Throwable th2) { SigmobLog.e(th2.getMessage()); x.a(PointCategory.APP_INSTALL_START, WindAdError.ERROR_SIGMOB_INSTALL_FAIL.getErrorCode(), th2.getMessage(), baseAdUnit); x.b(PointCategory.APP_INSTALL_START, "0", baseAdUnit); return; } } } try { Toast.makeText(context, "下载失败", 0).show(); } catch (Throwable th3) { SigmobLog.e(th3.getMessage()); } x.a(PointCategory.DOWNLOAD_FAILED, 2, str, baseAdUnit); x.b(PointCategory.DOWNLOAD_END, "0", baseAdUnit); HashMap hashMap2 = new HashMap(); hashMap2.put("result", "0"); hashMap2.put("downloadId", Long.valueOf(j)); BaseBroadcastReceiver.a(context, baseAdUnit.getUuid(), hashMap2, IntentActions.ACTION_INTERSTITIAL_DOWNLOAD_END); } } /* access modifiers changed from: package-private */ public DownloadManager a(Context context) { return (DownloadManager) context.getSystemService("download"); } public void onReceive(Context context, Intent intent) { long longExtra = intent.getLongExtra("extra_download_id", -1); BaseAdUnit baseAdUnit = null; l.b(longExtra, null); String f = b.f(); File file = new File(f, longExtra + ".log"); Object readFromCache = FileUtil.readFromCache(file.getAbsolutePath()); if (readFromCache != null && (readFromCache instanceof BaseAdUnit)) { baseAdUnit = (BaseAdUnit) readFromCache; BaseAdUnit a = d.a(baseAdUnit.getUuid()); if (a != null) { baseAdUnit = a; } } FileUtil.deleteFile(file.getAbsolutePath()); String action = intent.getAction(); action.hashCode(); if (action.equals("android.intent.action.DOWNLOAD_COMPLETE") && baseAdUnit != null) { a(context, longExtra, baseAdUnit); } } }