翰林优商.apk(点击下载) / e.java


package com.mbridge.msdk.mbdownload;

import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.SparseArray;
import android.widget.Toast;
import androidx.core.app.NotificationCompat;
import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField;
import com.kuaishou.weapon.p0.h;
import com.mbridge.msdk.MBridgeConstans;
import com.mbridge.msdk.foundation.db.i;
import com.mbridge.msdk.foundation.tools.MBFileProvider;
import com.mbridge.msdk.foundation.tools.q;
import com.mbridge.msdk.foundation.tools.s;
import com.mbridge.msdk.foundation.tools.w;
import com.mbridge.msdk.mbdownload.b;
import com.ss.android.downloadad.api.constant.AdBaseConstants;
import com.tencent.smtt.sdk.TbsVideoCacheTask;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;

/* access modifiers changed from: package-private */
/* compiled from: DownloadTool */
public class e {
    private static final String a = "com.mbridge.msdk.mbdownload.e";
    private SparseArray<b> b;
    private Map<b.a, Messenger> c;
    private i d;

    public e(SparseArray<b> sparseArray, Map<b.a, Messenger> map, i iVar) {
        this.b = sparseArray;
        this.c = map;
        this.d = iVar;
    }

    /* access modifiers changed from: package-private */
    /* compiled from: DownloadTool */
    public static class b {
        k a;
        a b;
        int c;
        int d;
        b.a e;
        long[] f = new long[3];

        public b(b.a aVar, int i) {
            this.c = i;
            this.e = aVar;
        }
    }

    /* access modifiers changed from: package-private */
    /* compiled from: DownloadTool */
    public static class a extends h {
        String a;
        String b;
        String c;
        Context d;

        public a(Context context) {
            super(context);
            this.d = context;
        }

        public final a a(CharSequence charSequence) {
            Context context = this.d;
            int w = context != null ? s.w(context) : 0;
            if (!TextUtils.isEmpty(charSequence) && charSequence.toString().contains("%")) {
                this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_progress_status", "id"), 8);
            }
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_progress_progess", "id"), 0);
            if (w >= 26 && Build.VERSION.SDK_INT >= 26) {
                this.j.setTextViewText(q.a(this.e, "mbridge_download_notify_progress_progess", "id"), charSequence);
            } else if (Build.VERSION.SDK_INT >= 16) {
                this.j.setTextViewText(q.a(this.e, "mbridge_download_notify_progress_progess", "id"), charSequence);
            } else {
                this.b = charSequence.toString();
            }
            return this;
        }

        public final a b(CharSequence charSequence) {
            Context context = this.d;
            int w = context != null ? s.w(context) : 0;
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_progress_status", "id"), 0);
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_progress_progess", "id"), 8);
            if (w >= 26 && Build.VERSION.SDK_INT >= 26) {
                this.j.setTextViewText(q.a(this.e, "mbridge_download_notify_progress_status", "id"), charSequence);
            } else if (Build.VERSION.SDK_INT >= 16) {
                this.j.setTextViewText(q.a(this.e, "mbridge_download_notify_progress_status", "id"), charSequence);
            } else {
                this.b = charSequence.toString();
            }
            return this;
        }

        public final a c(CharSequence charSequence) {
            Context context = this.d;
            if ((context != null ? s.w(context) : 0) >= 26 && Build.VERSION.SDK_INT >= 26) {
                this.j.setTextViewText(q.a(this.e, "mbridge_download_notify_target_name", "id"), charSequence);
            } else if (Build.VERSION.SDK_INT >= 16) {
                this.j.setTextViewText(q.a(this.e, "mbridge_download_notify_target_name", "id"), charSequence);
            } else {
                this.a = charSequence.toString();
            }
            return this;
        }

        public final a a(String str) {
            Context context = this.d;
            if (context != null) {
                s.w(context);
            }
            if (!TextUtils.isEmpty(str)) {
                com.mbridge.msdk.foundation.same.c.b.a(this.d).a(str, new com.mbridge.msdk.foundation.same.c.c() {
                    /* class com.mbridge.msdk.mbdownload.e.a.AnonymousClass1 */

                    @Override // com.mbridge.msdk.foundation.same.c.c
                    public final void onFailedLoad(String str, String str2) {
                    }

                    @Override // com.mbridge.msdk.foundation.same.c.c
                    public final void onSuccessLoad(Bitmap bitmap, String str) {
                        if (!bitmap.isRecycled()) {
                            a.this.j.setImageViewBitmap(q.a(a.this.e, "mbridge_download_notify_target_icon", "id"), bitmap);
                        }
                    }
                });
            }
            return this;
        }

        public final a a() {
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_pause", "id"), 0);
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_continue", "id"), 8);
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_progress_status", "id"), 8);
            return this;
        }

        public final a b() {
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_pause", "id"), 8);
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_continue", "id"), 8);
            return this;
        }

        public final a c() {
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_pause", "id"), 8);
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_continue", "id"), 0);
            this.j.setViewVisibility(q.a(this.d, "mbridge_download_notify_progress_status", "id"), 8);
            return this;
        }

        public final a a(int i, int i2, boolean z) {
            if (Build.VERSION.SDK_INT >= 16) {
                try {
                    this.j.setProgressBar(q.a(this.e, "mbridge_download_notify_progress", "id"), i, i2, z);
                } catch (Exception e) {
                    w.d(e.a, e.getMessage());
                }
            } else {
                this.c = i2 + "%";
            }
            return this;
        }

        public final Notification d() {
            Context context = this.d;
            if ((context != null ? s.w(context) : 0) >= 26 && Build.VERSION.SDK_INT >= 26) {
                return this.h.build();
            }
            if (Build.VERSION.SDK_INT >= 16) {
                return this.g.build();
            }
            if (Build.VERSION.SDK_INT < 16) {
                this.f = new NotificationCompat.Builder(this.e).setTicker(this.a).setContentIntent(this.i).build();
            } else {
                this.f = new Notification.Builder(this.e).setTicker(this.a).setContentIntent(this.i).build();
            }
            return this.f;
        }
    }

    /* access modifiers changed from: package-private */
    public final a a(Context context, b.a aVar, int i, int i2) {
        Context applicationContext = context.getApplicationContext();
        a aVar2 = new a(applicationContext);
        PendingIntent.getActivity(applicationContext, 0, new Intent(), 134217728);
        if (aVar.q) {
            aVar2.e();
            a(applicationContext, aVar2, i, 2);
        }
        a(applicationContext, aVar2, i, 3);
        aVar2.a(aVar.j);
        g.f(applicationContext);
        aVar2.a(17301633).a(System.currentTimeMillis());
        if (aVar.i) {
            aVar2.a();
        }
        a c2 = aVar2.c(aVar.c);
        c2.a((CharSequence) (i2 + "%")).a(100, i2, false);
        aVar2.a(aVar.h).b(true);
        return aVar2;
    }

    private void a(Context context, a aVar, int i, int i2) {
        if (Build.VERSION.SDK_INT >= 16) {
            PendingIntent a2 = j.a(context, j.a(i, "continue"));
            PendingIntent a3 = j.a(context, j.a(i, "install or active"));
            PendingIntent a4 = j.a(context, j.a(i, "continue"));
            PendingIntent a5 = j.a(context, j.a(i, "parent_view_click"));
            if (i2 == 1) {
                aVar.j.setOnClickPendingIntent(q.a(context, "mbridge_download_notify_continue", "id"), a2);
            } else if (i2 == 2) {
                aVar.j.setOnClickPendingIntent(q.a(context, "mbridge_download_notify_pause", "id"), a4);
            } else if (i2 == 3) {
                aVar.j.setOnClickPendingIntent(q.a(context, "mbridge_download_notify_progress_status", "id"), a3);
            }
            aVar.j.setOnClickPendingIntent(q.a(context, "mbridge_download_notify_parent_view", "id"), a5);
        }
    }

    /* access modifiers changed from: package-private */
    public final boolean a(Context context) {
        List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = ((ActivityManager) context.getSystemService(TTDownloadField.TT_ACTIVITY)).getRunningAppProcesses();
        if (runningAppProcesses == null) {
            return false;
        }
        String packageName = context.getPackageName();
        for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
            if (runningAppProcessInfo.importance == 100 && runningAppProcessInfo.processName.equals(packageName)) {
                return true;
            }
        }
        return false;
    }

    /* access modifiers changed from: package-private */
    public final boolean a(b.a aVar, boolean z, Messenger messenger) {
        if (z) {
            int nextInt = new Random().nextInt(1000);
            Map<b.a, Messenger> map = this.c;
            if (map != null) {
                for (b.a aVar2 : map.keySet()) {
                    String str = a;
                    w.a(str, "_" + nextInt + " downling  " + aVar2.c + "   " + aVar2.d);
                }
            } else {
                String str2 = a;
                w.a(str2, "_" + nextInt + "downling  null");
            }
        }
        Map<b.a, Messenger> map2 = this.c;
        if (map2 == null) {
            return false;
        }
        for (b.a aVar3 : map2.keySet()) {
            if (aVar.f != null && aVar.f.equals(aVar3.f)) {
                this.c.put(aVar3, messenger);
                return true;
            } else if (aVar3.d.equals(aVar.d)) {
                this.c.put(aVar3, messenger);
                return true;
            }
        }
        return false;
    }

    /* access modifiers changed from: package-private */
    public final int a(b.a aVar) {
        for (int i = 0; i < this.b.size(); i++) {
            int keyAt = this.b.keyAt(i);
            if (aVar.f != null && aVar.f.equals(this.b.get(keyAt).e.f)) {
                return this.b.get(keyAt).c;
            }
            if (this.b.get(keyAt).e.d.equals(aVar.d)) {
                return this.b.get(keyAt).c;
            }
        }
        return -1;
    }

    private void b(Context context, int i) {
        Context applicationContext = context.getApplicationContext();
        NotificationManager notificationManager = (NotificationManager) applicationContext.getSystemService("notification");
        j.a();
        b bVar = this.b.get(i);
        bVar.b.e();
        a(applicationContext, bVar.b, i, 1);
        bVar.b.c(bVar.e.c).a(bVar.e.h).b(true);
        if (bVar.e.i) {
            bVar.b.c();
        }
        notificationManager.notify(i, bVar.b.d());
    }

    /* access modifiers changed from: package-private */
    public final void a(Context context, int i) {
        NotificationManager notificationManager = (NotificationManager) context.getApplicationContext().getSystemService("notification");
        b bVar = this.b.get(i);
        if (bVar != null) {
            String str = a;
            w.a(str, "download service clear cache " + bVar.e.c);
            if (bVar.a != null) {
                bVar.a.a(2);
            }
            notificationManager.cancel(bVar.c);
            if (this.c.containsKey(bVar.e)) {
                this.c.remove(bVar.e);
            }
            SparseArray<b> sparseArray = this.b;
            if (sparseArray.indexOfKey(bVar.c) >= 0) {
                sparseArray.remove(bVar.c);
            }
            this.d.b(i);
        }
    }

    /* access modifiers changed from: package-private */
    public final boolean a(c cVar, Intent intent) {
        try {
            Context applicationContext = cVar.c().getApplicationContext();
            String string = intent.getExtras().getString("com.mbridge.msdk.broadcast.download.msg");
            if (string == null) {
                return false;
            }
            String[] split = string.split(":");
            int parseInt = Integer.parseInt(split[0]);
            String trim = split[1].trim();
            if (parseInt == 0 || TextUtils.isEmpty(trim) || this.b.indexOfKey(parseInt) < 0) {
                return false;
            }
            b bVar = this.b.get(parseInt);
            k kVar = bVar.a;
            long j = bVar.f[0];
            long j2 = bVar.f[1];
            long j3 = bVar.f[2];
            if ("continue".equals(trim)) {
                if (kVar == null) {
                    w.a(a, "Receive action do play click new thread.");
                    if (!b(applicationContext)) {
                        Toast.makeText(applicationContext, g.d, 1).show();
                        return false;
                    }
                    k kVar2 = new k(cVar, bVar.e, parseInt, bVar.d);
                    bVar.a = kVar2;
                    kVar2.start();
                    Message obtain = Message.obtain();
                    obtain.what = 2;
                    obtain.arg1 = 7;
                    obtain.arg2 = parseInt;
                    try {
                        if (this.c.get(bVar.e) != null) {
                            this.c.get(bVar.e).send(obtain);
                        }
                    } catch (RemoteException e) {
                        w.b(a, "", e);
                    }
                    return true;
                } else if (kVar.c() == k.b) {
                    w.a(a, "Receive action do play click.");
                    if (!b(applicationContext)) {
                        Toast.makeText(applicationContext, g.d, 1).show();
                        return false;
                    }
                    kVar.b();
                    Message obtain2 = Message.obtain();
                    obtain2.what = 2;
                    obtain2.arg1 = 7;
                    obtain2.arg2 = parseInt;
                    try {
                        if (this.c.get(bVar.e) != null) {
                            this.c.get(bVar.e).send(obtain2);
                        }
                    } catch (RemoteException e2) {
                        w.b(a, "", e2);
                    }
                    return true;
                } else {
                    w.a(a, "Receive action do pause click.");
                    kVar.a();
                    try {
                        kVar.interrupt();
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    }
                    b(applicationContext, parseInt);
                    Message obtain3 = Message.obtain();
                    obtain3.what = 2;
                    obtain3.arg1 = 6;
                    obtain3.arg2 = parseInt;
                    try {
                        if (this.c.get(bVar.e) != null) {
                            this.c.get(bVar.e).send(obtain3);
                        }
                    } catch (RemoteException e4) {
                        w.b(a, "", e4);
                    }
                    return true;
                }
            } else if ("cancel".equals(trim)) {
                w.a(a, "Receive action do stop click.");
                if (kVar != null) {
                    try {
                        kVar.a(2);
                    } catch (Exception unused) {
                        Message obtain4 = Message.obtain();
                        obtain4.what = 5;
                        obtain4.arg1 = 5;
                        obtain4.arg2 = parseInt;
                        try {
                            if (this.c.get(bVar.e) != null) {
                                this.c.get(bVar.e).send(obtain4);
                            }
                        } catch (RemoteException unused2) {
                            a(applicationContext, parseInt);
                        }
                    } catch (Throwable th) {
                        Message obtain5 = Message.obtain();
                        obtain5.what = 5;
                        obtain5.arg1 = 5;
                        obtain5.arg2 = parseInt;
                        try {
                            if (this.c.get(bVar.e) != null) {
                                this.c.get(bVar.e).send(obtain5);
                            }
                        } catch (RemoteException unused3) {
                            a(applicationContext, parseInt);
                        }
                        throw th;
                    }
                }
                Message obtain6 = Message.obtain();
                obtain6.what = 5;
                obtain6.arg1 = 5;
                obtain6.arg2 = parseInt;
                if (this.c.get(bVar.e) != null) {
                    this.c.get(bVar.e).send(obtain6);
                }
                return true;
            } else if ("install or active".equals(trim)) {
                if (kVar != null) {
                    kVar.d();
                    return false;
                }
                a(applicationContext, parseInt);
                return false;
            } else if (!"parent_view_click".equals(trim)) {
                return false;
            } else {
                w.a("workthread", "clickParentView");
                int c2 = com.mbridge.msdk.foundation.db.e.a(i.a(applicationContext)).c(bVar.e.g);
                if (c2 == 5 || c2 == 6) {
                    String str = a;
                    w.a(str, "Receive action clickParentView to do play click.");
                    if (kVar == null) {
                        w.a(str, "Receive action do play click.");
                        if (!b(applicationContext)) {
                            Toast.makeText(applicationContext, g.d, 1).show();
                            return false;
                        }
                        k kVar3 = new k(cVar, bVar.e, bVar.c, bVar.d);
                        bVar.a = kVar3;
                        kVar3.start();
                        Message obtain7 = Message.obtain();
                        obtain7.what = 2;
                        obtain7.arg1 = 7;
                        obtain7.arg2 = bVar.c;
                        try {
                            if (this.c.get(bVar.e) == null) {
                                return false;
                            }
                            this.c.get(bVar.e).send(obtain7);
                            return false;
                        } catch (RemoteException e5) {
                            w.b(a, "", e5);
                            return false;
                        }
                    } else if (kVar.c() == k.b) {
                        w.a(str, "Receive action do play click.");
                        if (!b(applicationContext)) {
                            Toast.makeText(applicationContext, g.d, 1).show();
                            return false;
                        }
                        kVar.b();
                        Message obtain8 = Message.obtain();
                        obtain8.what = 2;
                        obtain8.arg1 = 7;
                        obtain8.arg2 = bVar.c;
                        try {
                            if (this.c.get(bVar.e) == null) {
                                return false;
                            }
                            this.c.get(bVar.e).send(obtain8);
                            return false;
                        } catch (RemoteException e6) {
                            w.b(a, "", e6);
                            return false;
                        }
                    } else {
                        w.a(str, "Receive action do pause click.");
                        kVar.a();
                        b(applicationContext, bVar.c);
                        Message obtain9 = Message.obtain();
                        obtain9.what = 2;
                        obtain9.arg1 = 6;
                        obtain9.arg2 = bVar.c;
                        try {
                            if (this.c.get(bVar.e) == null) {
                                return false;
                            }
                            this.c.get(bVar.e).send(obtain9);
                            return false;
                        } catch (RemoteException e7) {
                            w.b(a, "", e7);
                            return false;
                        }
                    }
                } else if ((c2 != 1 && c2 != 9 && c2 != 10 && c2 != 11) || kVar == null) {
                    return false;
                } else {
                    kVar.d();
                    return false;
                }
            }
        } catch (Exception e8) {
            e8.printStackTrace();
            return false;
        }
    }

    /* compiled from: DownloadTool */
    class c extends AsyncTask<String, Void, Integer> {
        public int a;
        public String b;
        private b.a d;
        private Context e;
        private NotificationManager f;

        /* 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[]] */
        /* access modifiers changed from: protected */
        @Override // android.os.AsyncTask
        public final /* synthetic */ Integer doInBackground(String[] strArr) {
            return 1;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        /* access modifiers changed from: protected */
        /* JADX WARNING: Removed duplicated region for block: B:28:0x00e7  */
        /* JADX WARNING: Removed duplicated region for block: B:31:0x00fd  */
        /* JADX WARNING: Removed duplicated region for block: B:36:0x0131 A[Catch:{ RemoteException -> 0x0143 }] */
        /* JADX WARNING: Removed duplicated region for block: B:49:? A[RETURN, SYNTHETIC] */
        @Override // android.os.AsyncTask
        public final /* synthetic */ void onPostExecute(Integer num) {
            Notification a2;
            Uri uri;
            try {
                if (num.intValue() == 1) {
                    Intent intent = new Intent("android.intent.action.VIEW");
                    intent.addFlags(268435456);
                    try {
                        if (s.w(this.e) < 24 || Build.VERSION.SDK_INT < 24) {
                            intent.setDataAndType(Uri.fromFile(new File(this.b)), AdBaseConstants.MIME_APK);
                            PendingIntent activity = PendingIntent.getActivity(this.e, 0, intent, 134217728);
                            Context context = this.e;
                            a2 = e.a(context, g.g(context), activity);
                            if (a2 != null) {
                                a2.flags = 16;
                                this.f.notify(this.a + 1, a2);
                            }
                            if (e.this.a(this.e)) {
                                this.f.cancel(this.a + 1);
                                this.e.startActivity(intent);
                            }
                            Bundle bundle = new Bundle();
                            bundle.putString(TbsVideoCacheTask.KEY_VIDEO_CACHE_PARAM_FILENAME, this.b);
                            Message obtain = Message.obtain();
                            obtain.what = 5;
                            obtain.arg1 = 1;
                            obtain.arg2 = this.a;
                            obtain.setData(bundle);
                            try {
                                if (e.this.c.get(this.d) == null) {
                                    ((Messenger) e.this.c.get(this.d)).send(obtain);
                                }
                            } catch (RemoteException unused) {
                                e.this.a(this.e, this.a);
                            }
                        } else {
                            Uri uri2 = null;
                            try {
                                if (!TextUtils.isEmpty(MBridgeConstans.FILE_PROVIDE_CUSTOM_PATH)) {
                                    Method method = Class.forName(MBridgeConstans.FILE_PROVIDE_CUSTOM_PATH).getMethod("getUriForFile", Context.class, String.class, File.class);
                                    uri = (Uri) method.invoke(null, this.e, this.e.getApplicationContext().getPackageName() + ".mbFileProvider", new File(this.b));
                                } else {
                                    Context context2 = this.e;
                                    uri = MBFileProvider.getUriForFile(context2, this.e.getApplicationContext().getPackageName() + ".mbFileProvider", new File(this.b));
                                }
                                uri2 = uri;
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                            if (uri2 != null) {
                                intent.setDataAndType(uri2, AdBaseConstants.MIME_APK);
                                intent.addFlags(1);
                            }
                            PendingIntent activity2 = PendingIntent.getActivity(this.e, 0, intent, 134217728);
                            Context context3 = this.e;
                            a2 = e.a(context3, g.g(context3), activity2);
                            if (a2 != null) {
                            }
                            if (e.this.a(this.e)) {
                            }
                            Bundle bundle2 = new Bundle();
                            bundle2.putString(TbsVideoCacheTask.KEY_VIDEO_CACHE_PARAM_FILENAME, this.b);
                            Message obtain2 = Message.obtain();
                            obtain2.what = 5;
                            obtain2.arg1 = 1;
                            obtain2.arg2 = this.a;
                            obtain2.setData(bundle2);
                            if (e.this.c.get(this.d) == null) {
                            }
                        }
                    } catch (Exception unused2) {
                        intent.setDataAndType(Uri.fromFile(new File(this.b)), AdBaseConstants.MIME_APK);
                    }
                } else {
                    this.f.cancel(this.a + 1);
                    Bundle bundle3 = new Bundle();
                    bundle3.putString(TbsVideoCacheTask.KEY_VIDEO_CACHE_PARAM_FILENAME, this.b);
                    Message obtain3 = Message.obtain();
                    obtain3.what = 5;
                    obtain3.arg1 = 3;
                    obtain3.arg2 = this.a;
                    obtain3.setData(bundle3);
                    try {
                        if (e.this.c.get(this.d) != null) {
                            ((Messenger) e.this.c.get(this.d)).send(obtain3);
                        }
                    } catch (RemoteException unused3) {
                        e.this.a(this.e, this.a);
                    }
                }
            } catch (Throwable unused4) {
            }
        }

        public c(Context context, int i, b.a aVar, String str) {
            Context applicationContext = context.getApplicationContext();
            this.e = applicationContext;
            this.f = (NotificationManager) applicationContext.getSystemService("notification");
            j.a();
            this.a = i;
            this.d = aVar;
            this.b = str;
        }

        /* access modifiers changed from: protected */
        public final void onPreExecute() {
            super.onPreExecute();
        }
    }

    public static boolean b(Context context) {
        try {
            int checkPermission = context.getPackageManager().checkPermission(h.b, context.getPackageName());
            boolean isConnectedOrConnecting = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo().isConnectedOrConnecting();
            if (checkPermission != 0 || !isConnectedOrConnecting) {
                return false;
            }
            return true;
        } catch (Exception unused) {
        }
    }

    public static String a(String str) {
        if (str == null) {
            return null;
        }
        try {
            byte[] bytes = str.getBytes();
            MessageDigest instance = MessageDigest.getInstance("MD5");
            instance.reset();
            instance.update(bytes);
            byte[] digest = instance.digest();
            StringBuffer stringBuffer = new StringBuffer();
            for (int i = 0; i < digest.length; i++) {
                stringBuffer.append(String.format("%02X", Byte.valueOf(digest[i])));
            }
            return stringBuffer.toString();
        } catch (Exception unused) {
            return str.replaceAll("[^[a-z][A-Z][0-9][.][_]]", "");
        }
    }

    public static String a() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date());
    }

    private static boolean a(String str, int i, int i2, int i3) {
        try {
            Class.forName("android.os.FileUtils").getMethod("setPermissions", String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE).invoke(null, str, Integer.valueOf(i), -1, -1);
            return true;
        } catch (ClassNotFoundException e) {
            w.a(a, "error when set permissions:", e);
            return false;
        } catch (NoSuchMethodException e2) {
            w.a(a, "error when set permissions:", e2);
            return false;
        } catch (IllegalArgumentException e3) {
            w.a(a, "error when set permissions:", e3);
            return false;
        } catch (IllegalAccessException e4) {
            w.a(a, "error when set permissions:", e4);
            return false;
        } catch (InvocationTargetException e5) {
            w.a(a, "error when set permissions:", e5);
            return false;
        }
    }

    public static Notification a(Context context, String str, PendingIntent pendingIntent) {
        if ((context != null ? s.w(context) : 0) >= 26) {
            try {
                if (Build.VERSION.SDK_INT >= 26) {
                    Resources resources = context.getResources();
                    if (resources == null) {
                        return new NotificationCompat.Builder(context, "download").setSmallIcon(17301634).setTicker(str).setWhen(System.currentTimeMillis()).setContentIntent(pendingIntent).build();
                    }
                    return new NotificationCompat.Builder(context, "download").setSmallIcon(17301634).setLargeIcon(BitmapFactory.decodeResource(resources, 17301634)).setTicker(str).setWhen(System.currentTimeMillis()).setContentIntent(pendingIntent).build();
                }
            } catch (Throwable th) {
                w.a("DownloadTool", th.getMessage());
                return null;
            }
        }
        if (Build.VERSION.SDK_INT < 16) {
            return new NotificationCompat.Builder(context).setSmallIcon(17301633).setTicker(str).setWhen(System.currentTimeMillis()).setContentIntent(pendingIntent).build();
        }
        return new Notification.Builder(context).setSmallIcon(17301633).setTicker(str).setWhen(System.currentTimeMillis()).setContentIntent(pendingIntent).build();
    }

    public static File a(String str, Context context, boolean[] zArr) throws IOException {
        if (Environment.getExternalStorageState().equals("mounted")) {
            File file = new File(com.mbridge.msdk.foundation.same.b.e.b(com.mbridge.msdk.foundation.same.b.c.MBRIDGE_700_APK) + "/download/.mb" + str);
            file.mkdirs();
            if (file.exists()) {
                zArr[0] = true;
                return file;
            }
        }
        String absolutePath = context.getCacheDir().getAbsolutePath();
        new File(absolutePath).mkdir();
        a(absolutePath, 505, -1, -1);
        String str2 = absolutePath + "/mbdownload";
        new File(str2).mkdir();
        a(str2, 505, -1, -1);
        File file2 = new File(str2);
        zArr[0] = false;
        return file2;
    }
}