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


package com.xiaomi.push.service;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.xiaomi.channel.commonutils.logger.b;
import com.xiaomi.push.bk;
import com.xiaomi.push.ho;
import com.xiaomi.push.i;
import com.xiaomi.push.l;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.WeakHashMap;

public class au {
    private static Context a;

    /* renamed from: a  reason: collision with other field name */
    private static Object f7540a;

    /* renamed from: a  reason: collision with other field name */
    private static WeakHashMap<Integer, au> f7541a = new WeakHashMap<>();

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

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

    private au(String str) {
        this.f7543a = str;
    }

    private static int a(String str) {
        if (Build.VERSION.SDK_INT < 24) {
            return -1;
        }
        try {
            return a.getPackageManager().getPackageUid(str, 0);
        } catch (Exception unused) {
            return -1;
        }
    }

    private static NotificationManager a() {
        return (NotificationManager) a.getSystemService(RemoteMessageConst.NOTIFICATION);
    }

    public static au a(Context context, String str) {
        a(context);
        int hashCode = str.hashCode();
        au auVar = f7541a.get(Integer.valueOf(hashCode));
        if (auVar != null) {
            return auVar;
        }
        au auVar2 = new au(str);
        f7541a.put(Integer.valueOf(hashCode), auVar2);
        return auVar2;
    }

    private static <T> T a(Object obj) {
        if (obj == null) {
            return null;
        }
        try {
            return (T) obj.getClass().getMethod("getList", new Class[0]).invoke(obj, new Object[0]);
        } catch (Exception unused) {
            return null;
        }
    }

    private static Object a(List list) {
        return Class.forName("android.content.pm.ParceledListSlice").getConstructor(List.class).newInstance(list);
    }

    public static String a(String str, String str2) {
        if (TextUtils.isEmpty(str)) {
            return str;
        }
        String a2 = a("mipush|%s|%s", str2, "");
        return str.startsWith(a2) ? a("mipush_%s_%s", str2, str.replace(a2, "")) : str;
    }

    private static String a(String str, String str2, String str3) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        return String.format(str, str2, str3);
    }

    private static void a(Context context) {
        if (a == null) {
            a = context.getApplicationContext();
            NotificationManager a2 = a();
            Boolean bool = (Boolean) bk.a((Object) a2, "isSystemConditionProviderEnabled", "xmsf_fake_condition_provider_path");
            m9676a("fwk is support.init:" + bool);
            boolean booleanValue = bool != null ? bool.booleanValue() : false;
            f7542a = booleanValue;
            if (booleanValue) {
                f7540a = bk.a((Object) a2, "getService", new Object[0]);
            }
        }
    }

    /* renamed from: a  reason: collision with other method in class */
    static void m9676a(String str) {
        b.m9051a("NMHelper:" + str);
    }

    /* renamed from: a  reason: collision with other method in class */
    private static boolean m9677a() {
        if (l.m9608a() && ax.a(a).a(ho.NotificationBelongToAppSwitch.a(), true)) {
            return f7542a;
        }
        return false;
    }

    /* renamed from: a  reason: collision with other method in class */
    public static boolean m9678a(Context context) {
        a(context);
        return m9677a();
    }

    /* renamed from: a  reason: collision with other method in class */
    private StatusBarNotification[] m9679a() {
        if (!l.m9609a(m9681a())) {
            return null;
        }
        try {
            String packageName = m9681a().getPackageName();
            Object a2 = bk.a(f7540a, "getActiveNotifications", packageName);
            if (a2 instanceof StatusBarNotification[]) {
                return (StatusBarNotification[]) a2;
            }
            return null;
        } catch (Throwable th) {
            m9676a("getAllNotifications error " + th);
            return null;
        }
    }

    private String b(String str) {
        return a(m9677a() ? "mipush|%s|%s" : "mipush_%s_%s", this.f7543a, str);
    }

    /* renamed from: a  reason: collision with other method in class */
    public NotificationChannel m9680a(String str) {
        try {
            if (!m9677a()) {
                return a().getNotificationChannel(str);
            }
            List<NotificationChannel> a2 = m9684a();
            if (a2 != null) {
                for (NotificationChannel notificationChannel : a2) {
                    if (str.equals(notificationChannel.getId())) {
                        return notificationChannel;
                    }
                }
            }
            return null;
        } catch (Exception e) {
            m9676a("getNotificationChannel error" + e);
        }
    }

    /* renamed from: a  reason: collision with other method in class */
    public Context m9681a() {
        return a;
    }

    /* renamed from: a  reason: collision with other method in class */
    public String m9682a() {
        return this.f7543a;
    }

    /* renamed from: a  reason: collision with other method in class */
    public String m9683a(String str) {
        return TextUtils.isEmpty(str) ? b() : l.m9609a(m9681a()) ? b(str) : str;
    }

    /* access modifiers changed from: package-private */
    /* renamed from: a  reason: collision with other method in class */
    public List<NotificationChannel> m9684a() {
        String str;
        String str2 = this.f7543a;
        List<NotificationChannel> list = null;
        try {
            if (m9677a()) {
                int a2 = a(str2);
                if (a2 != -1) {
                    Object obj = f7540a;
                    Object[] objArr = {str2, Integer.valueOf(a2), false};
                    str = "mipush|%s|%s";
                    list = (List) a(bk.a(obj, "getNotificationChannelsForPackage", objArr));
                } else {
                    str = null;
                }
            } else {
                list = a().getNotificationChannels();
                str = "mipush_%s_%s";
            }
            if (!l.m9608a() || list == null) {
                return list;
            }
            ArrayList arrayList = new ArrayList();
            String a3 = a(str, str2, "");
            for (NotificationChannel notificationChannel : list) {
                if (notificationChannel.getId().startsWith(a3)) {
                    arrayList.add(notificationChannel);
                }
            }
            return arrayList;
        } catch (Exception e) {
            m9676a("getNotificationChannels error " + e);
            return null;
        }
    }

    public void a(int i) {
        String str = this.f7543a;
        try {
            if (m9677a()) {
                int a2 = i.a();
                String packageName = m9681a().getPackageName();
                if (Build.VERSION.SDK_INT >= 30) {
                    bk.b(f7540a, "cancelNotificationWithTag", str, packageName, null, Integer.valueOf(i), Integer.valueOf(a2));
                } else {
                    bk.b(f7540a, "cancelNotificationWithTag", str, null, Integer.valueOf(i), Integer.valueOf(a2));
                }
                m9676a("cancel succ:" + i);
                return;
            }
            a().cancel(i);
        } catch (Exception e) {
            m9676a("cancel error" + e);
        }
    }

    public void a(int i, Notification notification) {
        String str = this.f7543a;
        NotificationManager a2 = a();
        try {
            int i2 = Build.VERSION.SDK_INT;
            if (m9677a()) {
                if (i2 >= 19) {
                    notification.extras.putString("xmsf_target_package", str);
                }
                if (i2 >= 29) {
                    a2.notifyAsPackage(str, null, i, notification);
                } else {
                    a2.notify(i, notification);
                }
            } else {
                a2.notify(i, notification);
            }
        } catch (Exception unused) {
        }
    }

    /* access modifiers changed from: package-private */
    public void a(NotificationChannel notificationChannel) {
        String str = this.f7543a;
        try {
            if (m9677a()) {
                int a2 = a(str);
                if (a2 != -1) {
                    Object a3 = a(Arrays.asList(notificationChannel));
                    bk.b(f7540a, "createNotificationChannelsForPackage", str, Integer.valueOf(a2), a3);
                    return;
                }
                return;
            }
            a().createNotificationChannel(notificationChannel);
        } catch (Exception e) {
            m9676a("createNotificationChannel error" + e);
        }
    }

    /* access modifiers changed from: package-private */
    public void a(NotificationChannel notificationChannel, boolean z) {
        String str = this.f7543a;
        if (z) {
            try {
                int a2 = a(str);
                if (a2 != -1) {
                    bk.b(f7540a, "updateNotificationChannelForPackage", str, Integer.valueOf(a2), notificationChannel);
                }
            } catch (Exception e) {
                m9676a("updateNotificationChannel error " + e);
            }
        } else {
            a(notificationChannel);
        }
    }

    /* renamed from: a  reason: collision with other method in class */
    public boolean m9685a(String str) {
        if (!TextUtils.isEmpty(str)) {
            return str.startsWith(b(""));
        }
        return false;
    }

    /* access modifiers changed from: package-private */
    public String b() {
        if (TextUtils.isEmpty(this.b)) {
            this.b = b("default");
        }
        return this.b;
    }

    /* access modifiers changed from: package-private */
    public String b(String str, String str2) {
        return !m9677a() ? str2 : str;
    }

    /* renamed from: b  reason: collision with other method in class */
    public List<StatusBarNotification> m9686b() {
        Object th;
        ArrayList arrayList = null;
        if (Build.VERSION.SDK_INT < 18) {
            return null;
        }
        String str = this.f7543a;
        NotificationManager a2 = a();
        try {
            if (m9677a()) {
                int a3 = i.a();
                if (a3 == -1) {
                    return null;
                }
                return (List) a(bk.a(f7540a, "getAppActiveNotifications", str, Integer.valueOf(a3)));
            }
            StatusBarNotification[] activeNotifications = Build.VERSION.SDK_INT >= 23 ? a2.getActiveNotifications() : m9679a();
            boolean a4 = l.m9608a();
            if (activeNotifications == null || activeNotifications.length <= 0) {
                return null;
            }
            ArrayList arrayList2 = new ArrayList();
            try {
                for (StatusBarNotification statusBarNotification : activeNotifications) {
                    if (!a4 || str.equals(av.c(statusBarNotification.getNotification()))) {
                        arrayList2.add(statusBarNotification);
                    }
                }
                return arrayList2;
            } catch (Throwable th2) {
                th = th2;
                arrayList = arrayList2;
                m9676a("getActiveNotifications error " + th);
                return arrayList;
            }
        } catch (Throwable th3) {
            th = th3;
            m9676a("getActiveNotifications error " + th);
            return arrayList;
        }
    }

    public String toString() {
        return "NotificationManagerHelper{" + this.f7543a + "}";
    }
}