大漢易經書院.apk(点击下载) / aj.java


package com.xiaomi.push.service;

import android.app.ActivityManager;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.Pair;
import android.widget.RemoteViews;
import com.huawei.hms.framework.common.hianalytics.CrashHianalyticsData;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import com.xiaomi.push.Cif;
import com.xiaomi.push.al;
import com.xiaomi.push.bk;
import com.xiaomi.push.ep;
import com.xiaomi.push.eq;
import com.xiaomi.push.er;
import com.xiaomi.push.es;
import com.xiaomi.push.g;
import com.xiaomi.push.hj;
import com.xiaomi.push.hw;
import com.xiaomi.push.l;
import com.xiaomi.push.service.at;
import com.xiaomi.push.w;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.json.JSONException;
import org.json.JSONObject;

public class aj {
    public static long a;

    /* renamed from: a  reason: collision with other field name */
    private static volatile ap f7521a;

    /* renamed from: a  reason: collision with other field name */
    private static final LinkedList<Pair<Integer, Cif>> f7522a = new LinkedList<>();

    /* renamed from: a  reason: collision with other field name */
    private static ExecutorService f7523a = Executors.newCachedThreadPool();

    /* access modifiers changed from: private */
    public static class a implements Callable<Bitmap> {
        private Context a;

        /* renamed from: a  reason: collision with other field name */
        private String f7524a;

        /* renamed from: a  reason: collision with other field name */
        private boolean f7525a;

        public a(String str, Context context, boolean z) {
            this.a = context;
            this.f7524a = str;
            this.f7525a = z;
        }

        /* renamed from: a */
        public Bitmap call() {
            if (TextUtils.isEmpty(this.f7524a)) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("Failed get online picture/icon resource cause picUrl is empty");
            } else if (this.f7524a.startsWith("http")) {
                at.b a2 = at.a(this.a, this.f7524a, this.f7525a);
                if (a2 != null) {
                    return a2.f7539a;
                }
                com.xiaomi.channel.commonutils.logger.b.m9051a("Failed get online picture/icon resource");
            } else {
                Bitmap a3 = at.a(this.a, this.f7524a);
                if (a3 != null) {
                    return a3;
                }
                com.xiaomi.channel.commonutils.logger.b.m9051a("Failed get online picture/icon resource");
                return a3;
            }
            return null;
        }
    }

    public static class b {
        long a = 0;

        /* renamed from: a  reason: collision with other field name */
        Notification f7526a;
    }

    public static class c {
        public long a = 0;

        /* renamed from: a  reason: collision with other field name */
        public String f7527a;

        /* renamed from: a  reason: collision with other field name */
        public boolean f7528a = false;
    }

    static int a(Context context, String str) {
        return context.getSharedPreferences("pref_notify_type", 0).getInt(str, Integer.MAX_VALUE);
    }

    private static int a(Context context, String str, String str2) {
        if (str.equals(context.getPackageName())) {
            return context.getResources().getIdentifier(str2, "drawable", str);
        }
        return 0;
    }

    private static int a(Context context, String str, Map<String, String> map, int i) {
        ComponentName a2;
        Intent b2 = b(context, str, map, i);
        if (b2 == null || (a2 = l.a(context, b2)) == null) {
            return 0;
        }
        return a2.hashCode();
    }

    private static int a(Map<String, String> map) {
        String str = map == null ? null : map.get("timeout");
        if (TextUtils.isEmpty(str)) {
            return 0;
        }
        try {
            return Integer.parseInt(str);
        } catch (Exception unused) {
            return 0;
        }
    }

    private static Notification a(Notification notification) {
        Object a2 = bk.a(notification, "extraNotification");
        if (a2 != null) {
            bk.a(a2, "setCustomizedIcon", true);
        }
        return notification;
    }

    private static PendingIntent a(Context context, Cif ifVar, String str, byte[] bArr, int i) {
        return a(context, ifVar, str, bArr, i, 0, a(context, ifVar, str));
    }

    private static PendingIntent a(Context context, Cif ifVar, String str, byte[] bArr, int i, int i2, boolean z) {
        Intent intent;
        ComponentName componentName;
        int i3 = c(ifVar) ? 1000 : m9665a(ifVar) ? PushConstants.WORK_RECEIVER_EVENT_CORE_ERROR : -1;
        hw a2 = ifVar.m9501a();
        String a3 = a2 != null ? a2.m9457a() : "";
        boolean a4 = m9665a(ifVar);
        if (a2 == null || TextUtils.isEmpty(a2.f7184e)) {
            if (a4) {
                componentName = new ComponentName("com.xiaomi.xmsf", "com.xiaomi.mipush.sdk.PushMessageHandler");
            } else {
                intent = new Intent("com.xiaomi.mipush.RECEIVE_MESSAGE");
                componentName = new ComponentName(str, "com.xiaomi.mipush.sdk.PushMessageHandler");
            }
            intent.setComponent(componentName);
            intent.putExtra("mipush_payload", bArr);
            intent.putExtra("mipush_notified", true);
            intent.addCategory(String.valueOf(i));
            intent.addCategory(String.valueOf(a3));
            intent.putExtra("notification_click_button", i2);
            intent.putExtra("messageId", a3);
            intent.putExtra("eventMessageType", i3);
            if (a4 || !z) {
                a(context, intent, ifVar, a2, a3, i2);
                return PendingIntent.getService(context, 0, intent, 134217728);
            }
            Intent intent2 = new Intent();
            intent2.setComponent(a(str));
            intent2.addFlags(276824064);
            intent2.putExtra("mipush_serviceIntent", intent);
            intent2.addCategory(String.valueOf(i));
            intent2.addCategory(String.valueOf(a3));
            intent2.addCategory(String.valueOf(i2));
            a(context, intent2, ifVar, a2, a3, i2);
            a(intent2);
            return PendingIntent.getActivity(context, 0, intent2, 134217728);
        }
        Intent intent3 = new Intent("android.intent.action.VIEW");
        intent3.setData(Uri.parse(a2.f7184e));
        try {
            String protocol = new URL(a2.f7184e).getProtocol();
            if (!"http".equals(protocol)) {
                if (!"https".equals(protocol)) {
                    intent3.setPackage(str);
                    intent3.addFlags(268435456);
                    intent3.putExtra("messageId", a3);
                    intent3.putExtra("eventMessageType", i3);
                    return PendingIntent.getActivity(context, 0, intent3, 134217728);
                }
            }
            av.a(context, intent3);
        } catch (MalformedURLException unused) {
            com.xiaomi.channel.commonutils.logger.b.m9051a("meet URL exception : " + a2.f7184e);
            intent3.setPackage(str);
        }
        intent3.addFlags(268435456);
        intent3.putExtra("messageId", a3);
        intent3.putExtra("eventMessageType", i3);
        return PendingIntent.getActivity(context, 0, intent3, 134217728);
    }

    private static PendingIntent a(Context context, String str, Cif ifVar, byte[] bArr, int i, int i2) {
        Map<String, String> a2 = ifVar.m9501a().m9458a();
        if (a2 == null) {
            return null;
        }
        boolean a3 = a(context, ifVar, str);
        if (a3) {
            return a(context, ifVar, str, bArr, i, i2, a3);
        }
        Intent a4 = m9661a(context, str, a2, i2);
        if (a4 != null) {
            return PendingIntent.getActivity(context, 0, a4, 134217728);
        }
        return null;
    }

    public static ComponentName a(String str) {
        return new ComponentName(str, "com.xiaomi.mipush.sdk.NotificationClickedActivity");
    }

    /* renamed from: a  reason: collision with other method in class */
    public static Intent m9661a(Context context, String str, Map<String, String> map, int i) {
        if (m9670b(map)) {
            return a(context, str, map, String.format("cust_btn_%s_ne", Integer.valueOf(i)), String.format("cust_btn_%s_iu", Integer.valueOf(i)), String.format("cust_btn_%s_ic", Integer.valueOf(i)), String.format("cust_btn_%s_wu", Integer.valueOf(i)));
        } else if (i == 1) {
            return a(context, str, map, "notification_style_button_left_notify_effect", "notification_style_button_left_intent_uri", "notification_style_button_left_intent_class", "notification_style_button_left_web_uri");
        } else {
            if (i == 2) {
                return a(context, str, map, "notification_style_button_mid_notify_effect", "notification_style_button_mid_intent_uri", "notification_style_button_mid_intent_class", "notification_style_button_mid_web_uri");
            }
            if (i == 3) {
                return a(context, str, map, "notification_style_button_right_notify_effect", "notification_style_button_right_intent_uri", "notification_style_button_right_intent_class", "notification_style_button_right_web_uri");
            }
            if (i != 4) {
                return null;
            }
            return a(context, str, map, "notification_colorful_button_notify_effect", "notification_colorful_button_intent_uri", "notification_colorful_button_intent_class", "notification_colorful_button_web_uri");
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:52:0x0100  */
    private static Intent a(Context context, String str, Map<String, String> map, String str2, String str3, String str4, String str5) {
        Intent intent;
        StringBuilder sb;
        Intent intent2;
        String str6;
        MalformedURLException e;
        URISyntaxException e2;
        String str7 = map.get(str2);
        if (TextUtils.isEmpty(str7)) {
            return null;
        }
        if (bh.a.equals(str7)) {
            try {
                intent = context.getPackageManager().getLaunchIntentForPackage(str);
            } catch (Exception e3) {
                com.xiaomi.channel.commonutils.logger.b.d("Cause: " + e3.getMessage());
            }
        } else {
            if (bh.b.equals(str7)) {
                if (map.containsKey(str3)) {
                    String str8 = map.get(str3);
                    if (str8 != null) {
                        try {
                            intent2 = Intent.parseUri(str8, 1);
                        } catch (URISyntaxException e4) {
                            e2 = e4;
                            intent2 = null;
                            sb = new StringBuilder("Cause: ");
                            str6 = e2.getMessage();
                            sb.append(str6);
                            com.xiaomi.channel.commonutils.logger.b.d(sb.toString());
                            intent = intent2;
                            if (intent != null) {
                            }
                            return null;
                        }
                        try {
                            intent2.setPackage(str);
                        } catch (URISyntaxException e5) {
                            e2 = e5;
                            sb = new StringBuilder("Cause: ");
                            str6 = e2.getMessage();
                            sb.append(str6);
                            com.xiaomi.channel.commonutils.logger.b.d(sb.toString());
                            intent = intent2;
                            if (intent != null) {
                            }
                            return null;
                        }
                    }
                } else if (map.containsKey(str4)) {
                    Intent intent3 = new Intent();
                    intent3.setComponent(new ComponentName(str, map.get(str4)));
                    intent = intent3;
                }
                intent = null;
            } else {
                if (bh.c.equals(str7)) {
                    String str9 = map.get(str5);
                    if (!TextUtils.isEmpty(str9)) {
                        String trim = str9.trim();
                        if (!trim.startsWith("http://") && !trim.startsWith("https://")) {
                            trim = "http://" + trim;
                        }
                        try {
                            String protocol = new URL(trim).getProtocol();
                            if ("http".equals(protocol) || "https".equals(protocol)) {
                                intent2 = new Intent("android.intent.action.VIEW");
                                try {
                                    intent2.setData(Uri.parse(trim));
                                    av.a(context, intent2);
                                } catch (MalformedURLException e6) {
                                    e = e6;
                                }
                            }
                        } catch (MalformedURLException e7) {
                            e = e7;
                            intent2 = null;
                            sb = new StringBuilder("Cause: ");
                            str6 = e.getMessage();
                            sb.append(str6);
                            com.xiaomi.channel.commonutils.logger.b.d(sb.toString());
                            intent = intent2;
                            if (intent != null) {
                            }
                            return null;
                        }
                    }
                }
                intent = null;
            }
            intent = intent2;
        }
        if (intent != null) {
            intent.addFlags(268435456);
            try {
                if (context.getPackageManager().resolveActivity(intent, 65536) != null) {
                    return intent;
                }
            } catch (Exception e8) {
                com.xiaomi.channel.commonutils.logger.b.d("Cause: " + e8.getMessage());
            }
        }
        return null;
    }

    private static Bitmap a(Context context, int i) {
        return a(context.getResources().getDrawable(i));
    }

    /* JADX INFO: finally extract failed */
    private static Bitmap a(Context context, String str, boolean z) {
        Future submit = f7523a.submit(new a(str, context, z));
        try {
            Bitmap bitmap = (Bitmap) submit.get(180, TimeUnit.SECONDS);
            if (bitmap != null) {
                return bitmap;
            }
            submit.cancel(true);
            return bitmap;
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            com.xiaomi.channel.commonutils.logger.b.a(e);
            submit.cancel(true);
            return null;
        } catch (Throwable th) {
            submit.cancel(true);
            throw th;
        }
    }

    public static Bitmap a(Drawable drawable) {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }
        int intrinsicWidth = drawable.getIntrinsicWidth();
        int i = 1;
        if (intrinsicWidth <= 0) {
            intrinsicWidth = 1;
        }
        int intrinsicHeight = drawable.getIntrinsicHeight();
        if (intrinsicHeight > 0) {
            i = intrinsicHeight;
        }
        Bitmap createBitmap = Bitmap.createBitmap(intrinsicWidth, i, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(createBitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return createBitmap;
    }

    private static RemoteViews a(Context context, Cif ifVar, byte[] bArr) {
        hw a2 = ifVar.m9501a();
        String a3 = a(ifVar);
        if (!(a2 == null || a2.m9458a() == null)) {
            Map<String, String> a4 = a2.m9458a();
            String str = a4.get("layout_name");
            String str2 = a4.get("layout_value");
            if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
                try {
                    Resources resourcesForApplication = context.getPackageManager().getResourcesForApplication(a3);
                    int identifier = resourcesForApplication.getIdentifier(str, "layout", a3);
                    if (identifier == 0) {
                        return null;
                    }
                    RemoteViews remoteViews = new RemoteViews(a3, identifier);
                    try {
                        JSONObject jSONObject = new JSONObject(str2);
                        if (jSONObject.has("text")) {
                            JSONObject jSONObject2 = jSONObject.getJSONObject("text");
                            Iterator<String> keys = jSONObject2.keys();
                            while (keys.hasNext()) {
                                String next = keys.next();
                                String string = jSONObject2.getString(next);
                                int identifier2 = resourcesForApplication.getIdentifier(next, "id", a3);
                                if (identifier2 > 0) {
                                    remoteViews.setTextViewText(identifier2, string);
                                }
                            }
                        }
                        if (jSONObject.has("image")) {
                            JSONObject jSONObject3 = jSONObject.getJSONObject("image");
                            Iterator<String> keys2 = jSONObject3.keys();
                            while (keys2.hasNext()) {
                                String next2 = keys2.next();
                                String string2 = jSONObject3.getString(next2);
                                int identifier3 = resourcesForApplication.getIdentifier(next2, "id", a3);
                                int identifier4 = resourcesForApplication.getIdentifier(string2, "drawable", a3);
                                if (identifier3 > 0) {
                                    remoteViews.setImageViewResource(identifier3, identifier4);
                                }
                            }
                        }
                        if (jSONObject.has(CrashHianalyticsData.TIME)) {
                            JSONObject jSONObject4 = jSONObject.getJSONObject(CrashHianalyticsData.TIME);
                            Iterator<String> keys3 = jSONObject4.keys();
                            while (keys3.hasNext()) {
                                String next3 = keys3.next();
                                String string3 = jSONObject4.getString(next3);
                                if (string3.length() == 0) {
                                    string3 = "yy-MM-dd hh:mm";
                                }
                                int identifier5 = resourcesForApplication.getIdentifier(next3, "id", a3);
                                if (identifier5 > 0) {
                                    remoteViews.setTextViewText(identifier5, new SimpleDateFormat(string3).format(new Date(System.currentTimeMillis())));
                                }
                            }
                        }
                        return remoteViews;
                    } catch (JSONException e) {
                        com.xiaomi.channel.commonutils.logger.b.a(e);
                        return null;
                    }
                } catch (PackageManager.NameNotFoundException e2) {
                    com.xiaomi.channel.commonutils.logger.b.a(e2);
                }
            }
        }
        return null;
    }

    private static er a(Context context, Cif ifVar, byte[] bArr, String str, int i) {
        PendingIntent a2;
        String a3 = a(ifVar);
        Map<String, String> a4 = ifVar.m9501a().m9458a();
        String str2 = a4.get("notification_style_type");
        er a5 = (!l.m9609a(context) || f7521a == null) ? null : f7521a.a(context, i, a3, a4);
        if (a5 != null) {
            a5.a(a4);
            return a5;
        } else if (Build.VERSION.SDK_INT >= 16 && PushConstants.PUSH_TYPE_UPLOAD_LOG.equals(str2)) {
            er erVar = new er(context);
            Bitmap a6 = TextUtils.isEmpty(a4.get("notification_bigPic_uri")) ? null : a(context, a4.get("notification_bigPic_uri"), false);
            if (a6 == null) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("can not get big picture.");
                return erVar;
            }
            Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle(erVar);
            bigPictureStyle.bigPicture(a6);
            bigPictureStyle.setSummaryText(str);
            bigPictureStyle.bigLargeIcon((Bitmap) null);
            erVar.setStyle(bigPictureStyle);
            return erVar;
        } else if (Build.VERSION.SDK_INT >= 16 && "1".equals(str2)) {
            er erVar2 = new er(context);
            erVar2.setStyle(new Notification.BigTextStyle().bigText(str));
            return erVar2;
        } else if (PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION.equals(str2) && l.m9608a()) {
            eq eqVar = new eq(context, a3);
            if (!TextUtils.isEmpty(a4.get("notification_banner_image_uri"))) {
                eqVar.a(a(context, a4.get("notification_banner_image_uri"), false));
            }
            if (!TextUtils.isEmpty(a4.get("notification_banner_icon_uri"))) {
                eqVar.b(a(context, a4.get("notification_banner_icon_uri"), false));
            }
            eqVar.a(a4);
            return eqVar;
        } else if (!PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START.equals(str2) || !l.m9608a()) {
            return new er(context);
        } else {
            es esVar = new es(context, i, a3);
            if (!TextUtils.isEmpty(a4.get("notification_colorful_button_text")) && (a2 = a(context, a3, ifVar, bArr, i, 4)) != null) {
                esVar.a(a4.get("notification_colorful_button_text"), a2).a(a4.get("notification_colorful_button_bg_color"));
            }
            if (!TextUtils.isEmpty(a4.get("notification_colorful_bg_color"))) {
                esVar.b(a4.get("notification_colorful_bg_color"));
            } else if (!TextUtils.isEmpty(a4.get("notification_colorful_bg_image_uri"))) {
                esVar.a(a(context, a4.get("notification_colorful_bg_image_uri"), false));
            }
            esVar.a(a4);
            return esVar;
        }
    }

    /* JADX DEBUG: Multi-variable search result rejected for r12v19, resolved type: int */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r12v20 */
    /* JADX WARN: Type inference failed for: r12v21 */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x02ca  */
    /* JADX WARNING: Removed duplicated region for block: B:155:0x03ef  */
    /* JADX WARNING: Removed duplicated region for block: B:169:0x043e  */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x00e1  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x01ab  */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x01ad  */
    /* JADX WARNING: Removed duplicated region for block: B:71:0x01bc  */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x027b  */
    private static b a(Context context, Cif ifVar, byte[] bArr, RemoteViews remoteViews, PendingIntent pendingIntent, int i) {
        er erVar;
        boolean z;
        Bitmap a2;
        boolean z2;
        boolean z3;
        String str;
        boolean z4;
        long currentTimeMillis;
        boolean z5;
        b bVar;
        int i2;
        String str2;
        Notification notification;
        int i3;
        boolean z6;
        Bitmap bitmap;
        int i4;
        Bitmap bitmap2;
        StringBuilder sb;
        String str3;
        boolean z7;
        int a3;
        b bVar2 = new b();
        hw a4 = ifVar.m9501a();
        String a5 = a(ifVar);
        Map<String, String> a6 = a4.m9458a();
        String[] a7 = a(context, a4);
        if (remoteViews != null) {
            erVar = new er(context);
            erVar.setCustomContentView(remoteViews);
        } else {
            erVar = (a6 == null || !a6.containsKey("notification_style_type")) ? new er(context) : a(context, ifVar, bArr, a7[1], i);
        }
        a(erVar, context, ifVar.b(), ifVar, bArr, i);
        erVar.setContentTitle(a7[0]);
        erVar.setContentText(a7[1]);
        long currentTimeMillis2 = System.currentTimeMillis();
        erVar.setWhen(currentTimeMillis2);
        String a8 = a(a6, "notification_show_when");
        if (!TextUtils.isEmpty(a8)) {
            erVar.setShowWhen(Boolean.parseBoolean(a8));
        } else if (Build.VERSION.SDK_INT >= 24) {
            erVar.setShowWhen(true);
        }
        erVar.setContentIntent(pendingIntent);
        int a9 = a(context, a5, "mipush_notification");
        int a10 = a(context, a5, "mipush_small_notification");
        if (a9 <= 0 || a10 <= 0) {
            if (!l.m9609a(context)) {
                String a11 = a(a6, "fcm_icon_uri");
                String a12 = a(a6, "fcm_icon_color");
                if (!TextUtils.isEmpty(a11) && !TextUtils.isEmpty(a12) && (a3 = a(context, a5, a11)) > 0) {
                    erVar.setSmallIcon(a3);
                    erVar.m9322a(a12);
                    z7 = true;
                    if (!z7) {
                        if (Build.VERSION.SDK_INT >= 23) {
                            erVar.setSmallIcon(Icon.createWithResource(a5, av.a(context, a5)));
                        } else {
                            erVar.setSmallIcon(b(context, a5));
                        }
                    }
                }
            }
            z7 = false;
            if (!z7) {
            }
        } else {
            erVar.setLargeIcon(a(context, a9));
            erVar.setSmallIcon(a10);
        }
        if (Build.VERSION.SDK_INT >= 23) {
            if (a6 == null) {
                bitmap2 = null;
                i4 = 1;
            } else {
                i4 = 1;
                bitmap2 = a(context, a6.get("notification_small_icon_uri"), true);
            }
            if (bitmap2 != null) {
                Object[] objArr = new Object[i4];
                objArr[0] = bitmap2;
                Object a13 = bk.a("android.graphics.drawable.Icon", "createWithBitmap", objArr);
                if (a13 != null) {
                    Object[] objArr2 = new Object[i4];
                    objArr2[0] = a13;
                    bk.a((Object) erVar, "setSmallIcon", objArr2);
                    Bundle bundle = new Bundle();
                    bundle.putBoolean("miui.isGrayscaleIcon", i4);
                    erVar.addExtras(bundle);
                    erVar.m9322a(a(a6, "notification_small_icon_color"));
                } else {
                    sb = new StringBuilder("failed te get small icon with url:");
                    str3 = a6.get("notification_small_icon_uri");
                }
            } else {
                sb = new StringBuilder("failed to get small icon url:");
                str3 = a(a6, "notification_small_icon_uri");
            }
            sb.append(str3);
            com.xiaomi.channel.commonutils.logger.b.m9051a(sb.toString());
            erVar.m9322a(a(a6, "notification_small_icon_color"));
        }
        String a14 = a(a6, "__dynamic_icon_uri");
        boolean z8 = Boolean.parseBoolean(a(a6, "__adiom")) || !l.m9608a();
        if (!TextUtils.isEmpty(a14) && z8) {
            if (a14.startsWith("http")) {
                at.b a15 = at.a(context, a14, true);
                if (a15 != null) {
                    bitmap = a15.f7539a;
                    bVar2.a = a15.a;
                } else {
                    bitmap = null;
                }
            } else {
                bitmap = at.a(context, a14);
            }
            if (bitmap != null) {
                erVar.setLargeIcon(bitmap);
                z = true;
                a2 = a6 != null ? null : a(context, a6.get("notification_large_icon_uri"), true);
                if (a2 != null) {
                    erVar.setLargeIcon(a2);
                }
                if (a6 != null || Build.VERSION.SDK_INT < 24) {
                    z4 = false;
                    str = null;
                    z3 = false;
                    z2 = true;
                } else {
                    String str4 = a6.get("notification_group");
                    boolean parseBoolean = Boolean.parseBoolean(a6.get("notification_is_summary"));
                    boolean parseBoolean2 = Boolean.parseBoolean(a6.get("notification_group_disable_default"));
                    if (TextUtils.isEmpty(str4) && (l.m9608a() || !parseBoolean2)) {
                        str4 = a(ifVar);
                    }
                    bk.a((Object) erVar, "setGroupSummary", Boolean.valueOf(parseBoolean));
                    String str5 = a6.get("notification_style_type");
                    if (!"com.xiaomi.xmsf".equals(context.getPackageName()) || (!PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION.equals(str5) && !PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START.equals(str5))) {
                        z4 = parseBoolean;
                        z3 = false;
                        z2 = true;
                        str = str4;
                    } else {
                        z3 = true;
                        z2 = true;
                        str = a(ifVar) + "_custom_" + currentTimeMillis2;
                        z4 = parseBoolean;
                    }
                }
                erVar.setAutoCancel(z2);
                currentTimeMillis = System.currentTimeMillis();
                if (a6 != null && a6.containsKey(RemoteMessageConst.Notification.TICKER)) {
                    erVar.setTicker(a6.get(RemoteMessageConst.Notification.TICKER));
                }
                if (currentTimeMillis - a <= 10000) {
                    a = currentTimeMillis;
                    i2 = a4.f7171a;
                    if (m9668b(context, a5)) {
                        i2 = a(context, a5);
                    }
                    erVar.setDefaults(i2);
                    if (!(a6 == null || (i2 & 1) == 0)) {
                        String str6 = a6.get("sound_uri");
                        if (!TextUtils.isEmpty(str6)) {
                            bVar = bVar2;
                            z5 = z;
                            if (str6.startsWith("android.resource://" + a5)) {
                                erVar.setDefaults(i2 ^ 1);
                                erVar.setSound(Uri.parse(str6));
                            }
                        }
                    }
                    z5 = z;
                    bVar = bVar2;
                } else {
                    z5 = z;
                    bVar = bVar2;
                    i2 = -100;
                }
                if (a6 != null || Build.VERSION.SDK_INT < 26) {
                    str2 = "com.xiaomi.xmsf";
                    if (a6 != null && Build.VERSION.SDK_INT >= 16 && Build.VERSION.SDK_INT < 26) {
                        bk.a((Object) erVar, "setPriority", Integer.valueOf(c(a6)));
                    }
                } else {
                    au a16 = au.a(context, a5);
                    int a17 = a(a6);
                    if (a17 > 0) {
                        str2 = "com.xiaomi.xmsf";
                        z6 = z4;
                        i3 = i2;
                        bk.a((Object) erVar, "setTimeoutAfter", Long.valueOf((long) (a17 * 1000)));
                    } else {
                        z6 = z4;
                        i3 = i2;
                        str2 = "com.xiaomi.xmsf";
                    }
                    aq.a(a4);
                    String str7 = a6.get("channel_id");
                    if (!TextUtils.isEmpty(str7) || context.getApplicationInfo().targetSdkVersion >= 26) {
                        String a18 = a(context, a5, a6);
                        int b2 = b(a6);
                        int i5 = a4.f7171a;
                        bz.a(context, a6, erVar, currentTimeMillis2);
                        bk.a((Object) erVar, "setChannelId", aq.a(a16, str7, a18, a6.get("channel_description"), i5, b2, a6.get("sound_uri"), a6.get("channel_perm")));
                        if (i3 == -100 && av.a(a6)) {
                            av.a(erVar, z6);
                        }
                        if ("pulldown".equals(av.a((Object) a6)) && av.a(a6) && C$r8$backportedMethods$utility$Objects$2$equals.equals(a6.get("pull_down_pop_type"), PushConstants.PUSH_TYPE_NOTIFY)) {
                            av.a(erVar, z6);
                        }
                        if ("tts".equals(av.a((Object) a6)) && av.a(a6)) {
                            av.a(erVar, z6);
                        }
                    }
                    String str8 = a6.get("background_color");
                    if (!TextUtils.isEmpty(str8)) {
                        try {
                            int parseInt = Integer.parseInt(str8);
                            erVar.setOngoing(true);
                            erVar.setColor(parseInt);
                            bk.a((Object) erVar, "setColorized", true);
                        } catch (Exception e) {
                            com.xiaomi.channel.commonutils.logger.b.a(e);
                        }
                    }
                }
                if (str != null) {
                    if (!z3) {
                        str = ar.a().a(context, erVar, str);
                    }
                    bk.a((Object) erVar, "setGroup", str);
                }
                if (l.m9613c() && str2.equals(context.getPackageName())) {
                    bk.a("miui.util.NotificationHelper", "setTargetPkg", context, erVar, a(ifVar));
                }
                notification = erVar.getNotification();
                if (z5 && l.m9608a()) {
                    a(notification);
                }
                if (a6 != null) {
                    if (notification.extras == null) {
                        notification.extras = new Bundle();
                    }
                    if (!TextUtils.isEmpty(a6.get("enable_keyguard"))) {
                        av.b(notification, Boolean.parseBoolean(a6.get("enable_keyguard")));
                    }
                    if (!TextUtils.isEmpty(a6.get("enable_float"))) {
                        av.a(notification, Boolean.parseBoolean(a6.get("enable_float")));
                    }
                    if (!TextUtils.isEmpty(a6.get("float_small_win")) && PushConstants.PUSH_TYPE_NOTIFY.equals(a6.get("float_small_win")) && g.d(context, a5)) {
                        av.a(notification, false);
                    }
                    int a19 = w.a(a6.get("section_is_prr"), -1);
                    int a20 = w.a(a6.get("section_prr_cl"), -1);
                    if (a19 >= 0 && a20 >= 0) {
                        av.a(notification, a19, a20);
                    }
                }
                bVar.f7526a = notification;
                return bVar;
            }
        }
        z = false;
        if (a6 != null) {
        }
        if (a2 != null) {
        }
        if (a6 != null) {
        }
        z4 = false;
        str = null;
        z3 = false;
        z2 = true;
        erVar.setAutoCancel(z2);
        currentTimeMillis = System.currentTimeMillis();
        erVar.setTicker(a6.get(RemoteMessageConst.Notification.TICKER));
        if (currentTimeMillis - a <= 10000) {
        }
        if (a6 != null) {
        }
        str2 = "com.xiaomi.xmsf";
        bk.a((Object) erVar, "setPriority", Integer.valueOf(c(a6)));
        if (str != null) {
        }
        bk.a("miui.util.NotificationHelper", "setTargetPkg", context, erVar, a(ifVar));
        notification = erVar.getNotification();
        a(notification);
        if (a6 != null) {
        }
        bVar.f7526a = notification;
        return bVar;
    }

    /* JADX WARNING: Removed duplicated region for block: B:132:0x03c4  */
    /* JADX WARNING: Removed duplicated region for block: B:135:0x03e5  */
    /* JADX WARNING: Removed duplicated region for block: B:138:0x0406  */
    /* JADX WARNING: Removed duplicated region for block: B:147:0x0445 A[SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x021a  */
    /* JADX WARNING: Removed duplicated region for block: B:71:0x026f  */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x0287  */
    /* JADX WARNING: Removed duplicated region for block: B:81:0x02b1  */
    /* JADX WARNING: Removed duplicated region for block: B:82:0x02b3  */
    /* JADX WARNING: Removed duplicated region for block: B:85:0x02c5  */
    /* JADX WARNING: Removed duplicated region for block: B:88:0x02e2  */
    /* JADX WARNING: Removed duplicated region for block: B:89:0x02e5  */
    /* JADX WARNING: Removed duplicated region for block: B:95:0x0309  */
    /* JADX WARNING: Removed duplicated region for block: B:96:0x030b  */
    /* renamed from: a  reason: collision with other method in class */
    public static c m9662a(Context context, Cif ifVar, byte[] bArr) {
        Map<String, String> map;
        int i;
        RemoteViews a2;
        c cVar;
        Notification notification;
        String str;
        au a3;
        Cif ifVar2;
        String str2;
        Map<String, String> a4;
        long currentTimeMillis;
        StringBuilder sb;
        Object e;
        String str3;
        c cVar2 = new c();
        g.a a5 = g.a(context, a(ifVar), true);
        hw a6 = ifVar.m9501a();
        String str4 = null;
        if (a6 != null) {
            i = a6.c();
            map = a6.m9458a();
        } else {
            map = null;
            i = 0;
        }
        int b2 = w.b(a(ifVar), i);
        if (l.m9609a(context) && a5 == g.a.NOT_ALLOWED) {
            if (a6 != null) {
                ep.a(context.getApplicationContext()).a(ifVar.b(), b(ifVar), a6.m9457a(), "10:" + a(ifVar));
            }
            str3 = "Do not notify because user block " + a(ifVar) + "‘s notification";
        } else if (!l.m9609a(context) || f7521a == null || !f7521a.m9671a(context, b2, a(ifVar), map)) {
            a2 = a(context, ifVar, bArr);
            PendingIntent a7 = a(context, ifVar, ifVar.b(), bArr, b2);
            if (a7 == null) {
                if (a6 != null) {
                    ep.a(context.getApplicationContext()).a(ifVar.b(), b(ifVar), a6.m9457a(), "11");
                }
                str3 = "The click PendingIntent is null. ";
            } else {
                if (Build.VERSION.SDK_INT >= 11) {
                    b a8 = a(context, ifVar, bArr, a2, a7, b2);
                    cVar2.a = a8.a;
                    cVar2.f7527a = a(ifVar);
                    notification = a8.f7526a;
                    cVar = cVar2;
                } else {
                    cVar = cVar2;
                    notification = new Notification(b(context, a(ifVar)), null, System.currentTimeMillis());
                    String[] a9 = a(context, a6);
                    try {
                        notification.getClass().getMethod("setLatestEventInfo", Context.class, CharSequence.class, CharSequence.class, PendingIntent.class).invoke(notification, context, a9[0], a9[1], a7);
                    } catch (NoSuchMethodException e2) {
                        e = e2;
                        if (a6 != null) {
                            ep.a(context.getApplicationContext()).b(ifVar.b(), b(ifVar), a6.m9457a(), PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION);
                        }
                        sb = new StringBuilder("meet no such method error. ");
                    } catch (IllegalAccessException e3) {
                        e = e3;
                        if (a6 != null) {
                            ep.a(context.getApplicationContext()).b(ifVar.b(), b(ifVar), a6.m9457a(), "5");
                        }
                        sb = new StringBuilder("meet illegal access error. ");
                    } catch (IllegalArgumentException e4) {
                        e = e4;
                        if (a6 != null) {
                            ep.a(context.getApplicationContext()).b(ifVar.b(), b(ifVar), a6.m9457a(), "6");
                        }
                        sb = new StringBuilder("meet illegal argument error. ");
                    } catch (InvocationTargetException e5) {
                        e = e5;
                        if (a6 != null) {
                            ep.a(context.getApplicationContext()).b(ifVar.b(), b(ifVar), a6.m9457a(), "7");
                        }
                        sb = new StringBuilder("meet invocation target error. ");
                    }
                    a4 = a6.m9458a();
                    if (a4 != null && a4.containsKey(RemoteMessageConst.Notification.TICKER)) {
                        notification.tickerText = a4.get(RemoteMessageConst.Notification.TICKER);
                    }
                    currentTimeMillis = System.currentTimeMillis();
                    if (currentTimeMillis - a > 10000) {
                        a = currentTimeMillis;
                        int i2 = a6.f7171a;
                        if (m9668b(context, a(ifVar))) {
                            i2 = a(context, a(ifVar));
                        }
                        notification.defaults = i2;
                        if (!(a4 == null || (i2 & 1) == 0)) {
                            String str5 = a4.get("sound_uri");
                            if (!TextUtils.isEmpty(str5)) {
                                if (str5.startsWith("android.resource://" + a(ifVar))) {
                                    notification.defaults = i2 ^ 1;
                                    notification.sound = Uri.parse(str5);
                                }
                            }
                        }
                    }
                    notification.flags |= 16;
                    if (a2 != null) {
                        notification.contentView = a2;
                    }
                }
                if (l.m9608a() && Build.VERSION.SDK_INT >= 19) {
                    if (!TextUtils.isEmpty(a6.m9457a())) {
                        notification.extras.putString("message_id", a6.m9457a());
                    }
                    notification.extras.putString("local_paid", ifVar.m9502a());
                    av.a(map, notification.extras, "msg_busi_type");
                    av.a(map, notification.extras, "disable_notification_flags");
                    str2 = a6.m9463b() != null ? null : a6.m9463b().get("score_info");
                    if (!TextUtils.isEmpty(str2)) {
                        notification.extras.putString("score_info", str2);
                    }
                    notification.extras.putString("pushUid", a(a6.f7175a, "n_stats_expose"));
                    int i3 = -1;
                    if (!c(ifVar)) {
                        i3 = 1000;
                    } else if (m9665a(ifVar)) {
                        i3 = PushConstants.WORK_RECEIVER_EVENT_CORE_ERROR;
                    }
                    notification.extras.putString("eventMessageType", String.valueOf(i3));
                    notification.extras.putString(HiAnalyticsConstant.BI_KEY_TARGET_PACKAGE, a(ifVar));
                }
                str = a6.m9458a() != null ? null : a6.m9458a().get("message_count");
                if (l.m9608a() && str != null) {
                    try {
                        av.a(notification, Integer.parseInt(str));
                    } catch (NumberFormatException e6) {
                        if (a6 != null) {
                            ep.a(context.getApplicationContext()).b(ifVar.b(), b(ifVar), a6.m9457a(), "8");
                        }
                        com.xiaomi.channel.commonutils.logger.b.d("fail to set message count. " + e6);
                    }
                }
                String a10 = a(ifVar);
                if (!l.m9613c() && l.m9609a(context)) {
                    av.m9687a(notification, a10);
                }
                a3 = au.a(context, a10);
                if (l.m9609a(context) || f7521a == null) {
                    ifVar2 = ifVar;
                } else {
                    ifVar2 = ifVar;
                    f7521a.a(ifVar2, a6.m9458a(), b2, notification);
                }
                if (l.m9609a(context) || f7521a == null || !f7521a.a(a6.m9458a(), b2, notification)) {
                    a3.a(b2, notification);
                    cVar.f7528a = true;
                } else {
                    com.xiaomi.channel.commonutils.logger.b.b("consume this notificaiton by agent");
                }
                if (l.m9608a() && l.m9609a(context)) {
                    ar.a().a(context, b2, notification);
                    bz.m9710a(context, a10, b2, a6.m9457a(), notification);
                }
                if (m9665a(ifVar)) {
                    ep.a(context.getApplicationContext()).a(ifVar.b(), b(ifVar), a6.m9457a(), 3002, null);
                }
                if (c(ifVar)) {
                    ep.a(context.getApplicationContext()).a(ifVar.b(), b(ifVar), a6.m9457a(), PushConstants.PUSHSERVICE_INFO_SEND_MESSAGE_BY_NOTIFICATION_SERVICE_ERROR, null);
                }
                if (Build.VERSION.SDK_INT < 26) {
                    if (a6 != null) {
                        str4 = a6.m9457a();
                    }
                    al a11 = al.a(context);
                    int a12 = a(a6.m9458a());
                    if (a12 > 0 && !TextUtils.isEmpty(str4)) {
                        String str6 = "n_timeout_" + str4;
                        a11.m9120a(str6);
                        a11.b(new ak(str6, a3, b2), a12);
                    }
                }
                Pair<Integer, Cif> pair = new Pair<>(Integer.valueOf(b2), ifVar2);
                synchronized (f7522a) {
                    f7522a.add(pair);
                    if (f7522a.size() > 100) {
                        f7522a.remove();
                    }
                }
                return cVar;
            }
        } else {
            if (a6 != null) {
                ep.a(context.getApplicationContext()).a(ifVar.b(), b(ifVar), a6.m9457a(), "14:" + a(ifVar));
            }
            str3 = "Do not notify because card notification is canceled or sequence incorrect";
        }
        com.xiaomi.channel.commonutils.logger.b.m9051a(str3);
        return cVar2;
        sb.append(e);
        com.xiaomi.channel.commonutils.logger.b.d(sb.toString());
        a4 = a6.m9458a();
        notification.tickerText = a4.get(RemoteMessageConst.Notification.TICKER);
        currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis - a > 10000) {
        }
        notification.flags |= 16;
        if (a2 != null) {
        }
        if (!TextUtils.isEmpty(a6.m9457a())) {
        }
        notification.extras.putString("local_paid", ifVar.m9502a());
        av.a(map, notification.extras, "msg_busi_type");
        av.a(map, notification.extras, "disable_notification_flags");
        if (a6.m9463b() != null) {
        }
        if (!TextUtils.isEmpty(str2)) {
        }
        notification.extras.putString("pushUid", a(a6.f7175a, "n_stats_expose"));
        int i32 = -1;
        if (!c(ifVar)) {
        }
        notification.extras.putString("eventMessageType", String.valueOf(i32));
        notification.extras.putString(HiAnalyticsConstant.BI_KEY_TARGET_PACKAGE, a(ifVar));
        if (a6.m9458a() != null) {
        }
        av.a(notification, Integer.parseInt(str));
        String a102 = a(ifVar);
        av.m9687a(notification, a102);
        a3 = au.a(context, a102);
        if (l.m9609a(context)) {
        }
        ifVar2 = ifVar;
        if (l.m9609a(context)) {
        }
        a3.a(b2, notification);
        cVar.f7528a = true;
        ar.a().a(context, b2, notification);
        bz.m9710a(context, a102, b2, a6.m9457a(), notification);
        if (m9665a(ifVar)) {
        }
        if (c(ifVar)) {
        }
        if (Build.VERSION.SDK_INT < 26) {
        }
        Pair<Integer, Cif> pair2 = new Pair<>(Integer.valueOf(b2), ifVar2);
        synchronized (f7522a) {
        }
    }

    private static String a(Context context, String str, Map<String, String> map) {
        return (map == null || TextUtils.isEmpty(map.get("channel_name"))) ? g.m9384b(context, str) : map.get("channel_name");
    }

    public static String a(Cif ifVar) {
        hw a2;
        if (!(!"com.xiaomi.xmsf".equals(ifVar.f7270b) || (a2 = ifVar.m9501a()) == null || a2.m9458a() == null)) {
            String str = a2.m9458a().get("miui_package_name");
            if (!TextUtils.isEmpty(str)) {
                return str;
            }
        }
        return ifVar.f7270b;
    }

    public static String a(Map<String, String> map, int i) {
        String format = i == 0 ? "notify_effect" : m9670b(map) ? String.format("cust_btn_%s_ne", Integer.valueOf(i)) : i == 1 ? "notification_style_button_left_notify_effect" : i == 2 ? "notification_style_button_mid_notify_effect" : i == 3 ? "notification_style_button_right_notify_effect" : i == 4 ? "notification_colorful_button_notify_effect" : null;
        if (map == null || format == null) {
            return null;
        }
        return map.get(format);
    }

    private static String a(Map<String, String> map, String str) {
        if (map != null) {
            return map.get(str);
        }
        return null;
    }

    private static void a(Context context, Intent intent, Cif ifVar, hw hwVar, String str, int i) {
        if (ifVar != null && hwVar != null && !TextUtils.isEmpty(str)) {
            String a2 = a(hwVar.m9458a(), i);
            if (TextUtils.isEmpty(a2)) {
                return;
            }
            if (bh.a.equals(a2) || bh.b.equals(a2) || bh.c.equals(a2)) {
                intent.putExtra("messageId", str);
                intent.putExtra("local_paid", ifVar.f7266a);
                if (!TextUtils.isEmpty(ifVar.f7270b)) {
                    intent.putExtra(HiAnalyticsConstant.BI_KEY_TARGET_PACKAGE, ifVar.f7270b);
                }
                intent.putExtra("job_key", a(hwVar.m9458a(), "jobkey"));
                intent.putExtra(i + "_target_component", a(context, ifVar.f7270b, hwVar.m9458a(), i));
            }
        }
    }

    /* renamed from: a  reason: collision with other method in class */
    public static void m9663a(Context context, String str) {
        a(context, str, -1);
    }

    public static void a(Context context, String str, int i) {
        a(context, str, i, -1);
    }

    public static void a(Context context, String str, int i, int i2) {
        boolean z;
        if (context != null && !TextUtils.isEmpty(str) && i >= -1) {
            au a2 = au.a(context, str);
            List<StatusBarNotification> b2 = a2.m9686b();
            if (!w.a(b2)) {
                LinkedList linkedList = new LinkedList();
                int i3 = 0;
                if (i == -1) {
                    z = true;
                } else {
                    i3 = ((str.hashCode() / 10) * 10) + i;
                    z = false;
                }
                if (Build.VERSION.SDK_INT >= 18) {
                    Iterator<StatusBarNotification> it = b2.iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            break;
                        }
                        StatusBarNotification next = it.next();
                        if (!TextUtils.isEmpty(String.valueOf(next.getId()))) {
                            int id = next.getId();
                            if (z) {
                                linkedList.add(next);
                                a2.a(id);
                            } else if (i3 == id) {
                                d.a(context, next, i2);
                                linkedList.add(next);
                                a2.a(id);
                                break;
                            }
                        }
                    }
                }
                a(context, linkedList);
            }
        }
    }

    public static void a(Context context, String str, String str2, String str3) {
        if (!(context == null || TextUtils.isEmpty(str) || TextUtils.isEmpty(str2) || TextUtils.isEmpty(str3))) {
            au a2 = au.a(context, str);
            List<StatusBarNotification> b2 = a2.m9686b();
            if (!w.a(b2)) {
                LinkedList linkedList = new LinkedList();
                if (Build.VERSION.SDK_INT >= 18) {
                    for (StatusBarNotification statusBarNotification : b2) {
                        Notification notification = statusBarNotification.getNotification();
                        if (notification != null && !TextUtils.isEmpty(String.valueOf(statusBarNotification.getId()))) {
                            int id = statusBarNotification.getId();
                            String a3 = av.a(notification);
                            String b3 = av.b(notification);
                            if (!TextUtils.isEmpty(a3) && !TextUtils.isEmpty(b3) && a(a3, str2) && a(b3, str3)) {
                                linkedList.add(statusBarNotification);
                                a2.a(id);
                            }
                        }
                    }
                }
                a(context, linkedList);
            }
        }
    }

    public static void a(Context context, LinkedList<? extends Object> linkedList) {
        if (linkedList != null && linkedList.size() > 0) {
            bw.a(context, "category_clear_notification", "clear_notification", (long) linkedList.size(), "");
        }
    }

    private static void a(Intent intent) {
        try {
            Method declaredMethod = intent.getClass().getDeclaredMethod("addMiuiFlags", Integer.TYPE);
            declaredMethod.setAccessible(true);
            declaredMethod.invoke(intent, 2);
        } catch (Exception e) {
            com.xiaomi.channel.commonutils.logger.b.b("insert flags error " + e);
        }
    }

    private static void a(er erVar, Context context, String str, Cif ifVar, byte[] bArr, int i) {
        PendingIntent a2;
        PendingIntent a3;
        PendingIntent a4;
        PendingIntent a5;
        Map<String, String> a6 = ifVar.m9501a().m9458a();
        if (!(TextUtils.equals(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, a6.get("notification_style_type")) || TextUtils.equals(PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION, a6.get("notification_style_type")))) {
            if (m9670b(a6)) {
                for (int i2 = 1; i2 <= 3; i2++) {
                    String str2 = a6.get(String.format("cust_btn_%s_n", Integer.valueOf(i2)));
                    if (!TextUtils.isEmpty(str2) && (a5 = a(context, str, ifVar, bArr, i, i2)) != null) {
                        erVar.addAction(0, str2, a5);
                    }
                }
                return;
            }
            if (!TextUtils.isEmpty(a6.get("notification_style_button_left_name")) && (a4 = a(context, str, ifVar, bArr, i, 1)) != null) {
                erVar.addAction(0, a6.get("notification_style_button_left_name"), a4);
            }
            if (!TextUtils.isEmpty(a6.get("notification_style_button_mid_name")) && (a3 = a(context, str, ifVar, bArr, i, 2)) != null) {
                erVar.addAction(0, a6.get("notification_style_button_mid_name"), a3);
            }
            if (!(TextUtils.isEmpty(a6.get("notification_style_button_right_name")) || (a2 = a(context, str, ifVar, bArr, i, 3)) == null)) {
                erVar.addAction(0, a6.get("notification_style_button_right_name"), a2);
            }
        }
    }

    private static boolean a(Context context, Cif ifVar, String str) {
        if (ifVar != null && ifVar.m9501a() != null && ifVar.m9501a().m9458a() != null && !TextUtils.isEmpty(str)) {
            return Boolean.parseBoolean(ifVar.m9501a().m9458a().get("use_clicked_activity")) && l.a(context, a(str));
        }
        com.xiaomi.channel.commonutils.logger.b.m9051a("should clicked activity params are null.");
        return false;
    }

    /* renamed from: a  reason: collision with other method in class */
    public static boolean m9664a(Context context, String str) {
        List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = ((ActivityManager) context.getSystemService(PushConstants.INTENT_ACTIVITY_NAME)).getRunningAppProcesses();
        if (runningAppProcesses == null) {
            return false;
        }
        for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
            if (runningAppProcessInfo.importance == 100 && Arrays.asList(runningAppProcessInfo.pkgList).contains(str)) {
                return true;
            }
        }
        return false;
    }

    private static boolean a(hw hwVar) {
        if (hwVar == null) {
            return false;
        }
        String a2 = hwVar.m9457a();
        return !TextUtils.isEmpty(a2) && a2.length() == 22 && "satuigmo".indexOf(a2.charAt(0)) >= 0;
    }

    /* renamed from: a  reason: collision with other method in class */
    public static boolean m9665a(Cif ifVar) {
        hw a2 = ifVar.m9501a();
        return a(a2) && a2.l();
    }

    private static boolean a(String str, String str2) {
        return TextUtils.isEmpty(str) || str2.contains(str);
    }

    /* renamed from: a  reason: collision with other method in class */
    public static boolean m9666a(Map<String, String> map) {
        if (map == null || !map.containsKey("notify_foreground")) {
            return true;
        }
        return "1".equals(map.get("notify_foreground"));
    }

    /* JADX WARNING: Code restructure failed: missing block: B:15:0x0070, code lost:
        if (android.text.TextUtils.isEmpty(r3) == false) goto L_0x0072;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:8:0x004e, code lost:
        if (android.text.TextUtils.isEmpty(r3) == false) goto L_0x0072;
     */
    private static String[] a(Context context, hw hwVar) {
        String str;
        String c2 = hwVar.m9465c();
        String d = hwVar.d();
        Map<String, String> a2 = hwVar.m9458a();
        if (a2 != null) {
            int intValue = Float.valueOf((((float) context.getResources().getDisplayMetrics().widthPixels) / context.getResources().getDisplayMetrics().density) + 0.5f).intValue();
            if (intValue <= 320) {
                String str2 = a2.get("title_short");
                if (!TextUtils.isEmpty(str2)) {
                    c2 = str2;
                }
                str = a2.get("description_short");
            } else if (intValue > 360) {
                String str3 = a2.get("title_long");
                if (!TextUtils.isEmpty(str3)) {
                    c2 = str3;
                }
                str = a2.get("description_long");
            }
            d = str;
        }
        return new String[]{c2, d};
    }

    private static int b(Context context, String str) {
        int a2 = a(context, str, "mipush_notification");
        int a3 = a(context, str, "mipush_small_notification");
        if (a2 <= 0) {
            a2 = a3 <= 0 ? context.getApplicationInfo().icon : a3;
        }
        return (a2 != 0 || Build.VERSION.SDK_INT < 9) ? a2 : context.getApplicationInfo().logo;
    }

    private static int b(Map<String, String> map) {
        if (map == null) {
            return 3;
        }
        String str = map.get("channel_importance");
        if (TextUtils.isEmpty(str)) {
            return 3;
        }
        try {
            com.xiaomi.channel.commonutils.logger.b.c("importance=" + str);
            return Integer.parseInt(str);
        } catch (Exception e) {
            com.xiaomi.channel.commonutils.logger.b.d("parsing channel importance error: " + e);
            return 3;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:65:0x0138  */
    public static Intent b(Context context, String str, Map<String, String> map, int i) {
        Intent intent;
        StringBuilder sb;
        Intent intent2;
        String str2;
        String str3;
        MalformedURLException e;
        URISyntaxException e2;
        if (map == null) {
            return null;
        }
        if (i != 0) {
            return m9661a(context, str, map, i);
        }
        if (!map.containsKey("notify_effect")) {
            return null;
        }
        String str4 = map.get("notify_effect");
        int i2 = -1;
        String str5 = map.get("intent_flag");
        try {
            if (!TextUtils.isEmpty(str5)) {
                i2 = Integer.parseInt(str5);
            }
        } catch (NumberFormatException e3) {
            com.xiaomi.channel.commonutils.logger.b.d("Cause by intent_flag: " + e3.getMessage());
        }
        if (bh.a.equals(str4)) {
            try {
                intent = context.getPackageManager().getLaunchIntentForPackage(str);
            } catch (Exception e4) {
                com.xiaomi.channel.commonutils.logger.b.d("Cause: " + e4.getMessage());
            }
        } else {
            if (bh.b.equals(str4)) {
                if (map.containsKey("intent_uri")) {
                    String str6 = map.get("intent_uri");
                    if (str6 != null) {
                        try {
                            intent2 = Intent.parseUri(str6, 1);
                            try {
                                intent2.setPackage(str);
                            } catch (URISyntaxException e5) {
                                e2 = e5;
                                sb = new StringBuilder("Cause: ");
                                str2 = e2.getMessage();
                                sb.append(str2);
                                com.xiaomi.channel.commonutils.logger.b.d(sb.toString());
                                intent = intent2;
                                if (intent != null) {
                                }
                                return null;
                            }
                        } catch (URISyntaxException e6) {
                            e2 = e6;
                            intent2 = null;
                            sb = new StringBuilder("Cause: ");
                            str2 = e2.getMessage();
                            sb.append(str2);
                            com.xiaomi.channel.commonutils.logger.b.d(sb.toString());
                            intent = intent2;
                            if (intent != null) {
                            }
                            return null;
                        }
                    }
                } else if (map.containsKey("class_name")) {
                    Intent intent3 = new Intent();
                    intent3.setComponent(new ComponentName(str, map.get("class_name")));
                    intent = intent3;
                }
                intent = null;
            } else {
                if (bh.c.equals(str4) && (str3 = map.get("web_uri")) != null) {
                    String trim = str3.trim();
                    if (!trim.startsWith("http://") && !trim.startsWith("https://")) {
                        trim = "http://" + trim;
                    }
                    try {
                        String protocol = new URL(trim).getProtocol();
                        if ("http".equals(protocol) || "https".equals(protocol)) {
                            intent2 = new Intent("android.intent.action.VIEW");
                            try {
                                intent2.setData(Uri.parse(trim));
                                av.a(context, intent2);
                            } catch (MalformedURLException e7) {
                                e = e7;
                            }
                        }
                    } catch (MalformedURLException e8) {
                        e = e8;
                        intent2 = null;
                        sb = new StringBuilder("Cause: ");
                        str2 = e.getMessage();
                        sb.append(str2);
                        com.xiaomi.channel.commonutils.logger.b.d(sb.toString());
                        intent = intent2;
                        if (intent != null) {
                        }
                        return null;
                    }
                }
                intent = null;
            }
            intent = intent2;
        }
        if (intent != null) {
            if (i2 >= 0) {
                intent.setFlags(i2);
            }
            intent.addFlags(268435456);
            try {
                if (context.getPackageManager().resolveActivity(intent, 65536) != null) {
                    return intent;
                }
                com.xiaomi.channel.commonutils.logger.b.m9051a("not resolve activity:" + intent);
            } catch (Exception e9) {
                com.xiaomi.channel.commonutils.logger.b.d("Cause: " + e9.getMessage());
            }
        }
        return null;
    }

    public static String b(Cif ifVar) {
        return m9665a(ifVar) ? "E100002" : c(ifVar) ? "E100000" : m9669b(ifVar) ? "E100001" : d(ifVar) ? "E100003" : "";
    }

    /* renamed from: b  reason: collision with other method in class */
    static void m9667b(Context context, String str) {
        context.getSharedPreferences("pref_notify_type", 0).edit().remove(str).commit();
    }

    static void b(Context context, String str, int i) {
        context.getSharedPreferences("pref_notify_type", 0).edit().putInt(str, i).commit();
    }

    /* renamed from: b  reason: collision with other method in class */
    static boolean m9668b(Context context, String str) {
        return context.getSharedPreferences("pref_notify_type", 0).contains(str);
    }

    /* renamed from: b  reason: collision with other method in class */
    public static boolean m9669b(Cif ifVar) {
        hw a2 = ifVar.m9501a();
        return a(a2) && a2.f7177b == 1 && !m9665a(ifVar);
    }

    /* renamed from: b  reason: collision with other method in class */
    private static boolean m9670b(Map<String, String> map) {
        if (map != null) {
            return "6".equals(map.get("notification_style_type"));
        }
        com.xiaomi.channel.commonutils.logger.b.m9051a("meta extra is null");
        return false;
    }

    private static int c(Map<String, String> map) {
        if (map == null) {
            return 0;
        }
        String str = map.get("notification_priority");
        if (TextUtils.isEmpty(str)) {
            return 0;
        }
        try {
            com.xiaomi.channel.commonutils.logger.b.c("priority=" + str);
            return Integer.parseInt(str);
        } catch (Exception e) {
            com.xiaomi.channel.commonutils.logger.b.d("parsing notification priority error: " + e);
            return 0;
        }
    }

    public static boolean c(Cif ifVar) {
        hw a2 = ifVar.m9501a();
        return a(a2) && a2.f7177b == 0 && !m9665a(ifVar);
    }

    public static boolean d(Cif ifVar) {
        return ifVar.a() == hj.Registration;
    }

    public static boolean e(Cif ifVar) {
        return m9665a(ifVar) || c(ifVar) || m9669b(ifVar);
    }
}