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


package com.xiaomi.mipush.sdk;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.text.TextUtils;
import com.huawei.hms.support.api.entity.auth.AuthCode;
import com.xiaomi.channel.commonutils.logger.b;
import com.xiaomi.push.Cif;
import com.xiaomi.push.bj;
import com.xiaomi.push.bo;
import com.xiaomi.push.db;
import com.xiaomi.push.ep;
import com.xiaomi.push.hj;
import com.xiaomi.push.hk;
import com.xiaomi.push.hn;
import com.xiaomi.push.ho;
import com.xiaomi.push.ht;
import com.xiaomi.push.hw;
import com.xiaomi.push.ii;
import com.xiaomi.push.ij;
import com.xiaomi.push.ip;
import com.xiaomi.push.it;
import com.xiaomi.push.iu;
import com.xiaomi.push.l;
import com.xiaomi.push.service.ax;
import com.xiaomi.push.service.ba;
import com.xiaomi.push.service.bh;
import com.xiaomi.push.service.bk;
import com.xiaomi.push.service.i;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

public class ao {
    private static ao a = null;

    /* renamed from: a  reason: collision with other field name */
    private static final ArrayList<a> f6692a = new ArrayList<>();
    private static boolean b = false;

    /* renamed from: a  reason: collision with other field name */
    private Context f6693a;

    /* renamed from: a  reason: collision with other field name */
    private Intent f6694a = null;

    /* renamed from: a  reason: collision with other field name */
    private Handler f6695a = null;

    /* renamed from: a  reason: collision with other field name */
    private Messenger f6696a;

    /* renamed from: a  reason: collision with other field name */
    private Integer f6697a = null;

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

    /* renamed from: a  reason: collision with other field name */
    private List<Message> f6699a = new ArrayList();

    /* renamed from: a  reason: collision with other field name */
    private boolean f6700a = false;
    private boolean c = false;

    /* access modifiers changed from: package-private */
    public static class a<T extends iu<T, ?>> {
        hj a;

        /* renamed from: a  reason: collision with other field name */
        T f6701a;

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

        a() {
        }
    }

    private ao(Context context) {
        this.f6693a = context.getApplicationContext();
        this.f6698a = null;
        this.f6700a = m9074c();
        b = m9075d();
        this.f6695a = new ap(this, Looper.getMainLooper());
        if (l.m9609a(context)) {
            i.a(new aq(this));
        }
        Intent b2 = b();
        if (b2 != null) {
            b(b2);
        }
    }

    private synchronized int a() {
        return this.f6693a.getSharedPreferences("mipush_extra", 0).getInt(Constants.EXTRA_KEY_BOOT_SERVICE_MODE, -1);
    }

    /* renamed from: a  reason: collision with other method in class */
    private Intent m9072a() {
        return (!m9079a() || "com.xiaomi.xmsf".equals(this.f6693a.getPackageName())) ? e() : d();
    }

    private Message a(Intent intent) {
        Message obtain = Message.obtain();
        obtain.what = 17;
        obtain.obj = intent;
        return obtain;
    }

    public static synchronized ao a(Context context) {
        ao aoVar;
        synchronized (ao.class) {
            if (a == null) {
                a = new ao(context);
            }
            aoVar = a;
        }
        return aoVar;
    }

    /* renamed from: a  reason: collision with other method in class */
    private String m9073a() {
        try {
            return this.f6693a.getPackageManager().getPackageInfo("com.xiaomi.xmsf", 4).versionCode >= 106 ? "com.xiaomi.push.service.XMPushService" : "com.xiaomi.xmsf.push.service.XMPushService";
        } catch (Exception unused) {
            return "com.xiaomi.xmsf.push.service.XMPushService";
        }
    }

    /* access modifiers changed from: private */
    public void a(String str, au auVar, boolean z, HashMap<String, String> hashMap) {
        ii iiVar;
        String str2;
        if (b.m9086a(this.f6693a).m9093b() && bj.b(this.f6693a)) {
            ii iiVar2 = new ii();
            iiVar2.a(true);
            Intent a2 = m9072a();
            if (TextUtils.isEmpty(str)) {
                str = ba.a();
                iiVar2.a(str);
                iiVar = z ? new ii(str, true) : null;
                synchronized (af.class) {
                    af.a(this.f6693a).m9068a(str);
                }
            } else {
                iiVar2.a(str);
                iiVar = z ? new ii(str, true) : null;
            }
            switch (at.a[auVar.ordinal()]) {
                case 1:
                    iiVar2.c(ht.DisablePushMessage.f7140a);
                    iiVar.c(ht.DisablePushMessage.f7140a);
                    if (hashMap != null) {
                        iiVar2.a(hashMap);
                        iiVar.a(hashMap);
                    }
                    str2 = "com.xiaomi.mipush.DISABLE_PUSH_MESSAGE";
                    a2.setAction(str2);
                    break;
                case 2:
                    iiVar2.c(ht.EnablePushMessage.f7140a);
                    iiVar.c(ht.EnablePushMessage.f7140a);
                    if (hashMap != null) {
                        iiVar2.a(hashMap);
                        iiVar.a(hashMap);
                    }
                    str2 = "com.xiaomi.mipush.ENABLE_PUSH_MESSAGE";
                    a2.setAction(str2);
                    break;
                case 3:
                case 4:
                case 5:
                case 6:
                    iiVar2.c(ht.ThirdPartyRegUpdate.f7140a);
                    if (hashMap != null) {
                        iiVar2.a(hashMap);
                        break;
                    }
                    break;
            }
            b.e("type:" + auVar + ", " + str);
            iiVar2.b(b.m9086a(this.f6693a).m9087a());
            iiVar2.d(this.f6693a.getPackageName());
            a((iu) iiVar2, hj.Notification, false, (hw) null);
            if (z) {
                iiVar.b(b.m9086a(this.f6693a).m9087a());
                iiVar.d(this.f6693a.getPackageName());
                byte[] a3 = it.a(ai.a(this.f6693a, iiVar, hj.Notification, false, this.f6693a.getPackageName(), b.m9086a(this.f6693a).m9087a()));
                if (a3 != null) {
                    db.a(this.f6693a.getPackageName(), this.f6693a, iiVar, hj.Notification, a3.length);
                    a2.putExtra("mipush_payload", a3);
                    a2.putExtra("com.xiaomi.mipush.MESSAGE_CACHE", true);
                    a2.putExtra("mipush_app_id", b.m9086a(this.f6693a).m9087a());
                    a2.putExtra("mipush_app_token", b.m9086a(this.f6693a).b());
                    c(a2);
                }
            }
            Message obtain = Message.obtain();
            obtain.what = 19;
            int ordinal = auVar.ordinal();
            obtain.obj = str;
            obtain.arg1 = ordinal;
            this.f6695a.sendMessageDelayed(obtain, 5000);
        }
    }

    private Intent b() {
        if (!"com.xiaomi.xmsf".equals(this.f6693a.getPackageName())) {
            return c();
        }
        b.c("pushChannel xmsf create own channel");
        return e();
    }

    private void b(Intent intent) {
        try {
            if (l.m9608a() || Build.VERSION.SDK_INT < 26) {
                this.f6693a.startService(intent);
            } else {
                d(intent);
            }
        } catch (Exception e) {
            b.a(e);
        }
    }

    private Intent c() {
        if (m9079a()) {
            b.c("pushChannel app start miui china channel");
            return d();
        }
        b.c("pushChannel app start  own channel");
        return e();
    }

    private synchronized void c(int i) {
        this.f6693a.getSharedPreferences("mipush_extra", 0).edit().putInt(Constants.EXTRA_KEY_BOOT_SERVICE_MODE, i).commit();
    }

    private void c(Intent intent) {
        int a2 = ax.a(this.f6693a).a(ho.ServiceBootMode.a(), hk.START.a());
        int a3 = a();
        boolean z = a2 == hk.BIND.a() && b;
        int a4 = (z ? hk.BIND : hk.START).a();
        if (a4 != a3) {
            m9080a(a4);
        }
        if (z) {
            d(intent);
        } else {
            b(intent);
        }
    }

    /* renamed from: c  reason: collision with other method in class */
    private boolean m9074c() {
        try {
            PackageInfo packageInfo = this.f6693a.getPackageManager().getPackageInfo("com.xiaomi.xmsf", 4);
            return packageInfo != null && packageInfo.versionCode >= 105;
        } catch (Throwable unused) {
            return false;
        }
    }

    private Intent d() {
        Intent intent = new Intent();
        String packageName = this.f6693a.getPackageName();
        intent.setPackage("com.xiaomi.xmsf");
        intent.setClassName("com.xiaomi.xmsf", m9073a());
        intent.putExtra("mipush_app_package", packageName);
        f();
        return intent;
    }

    private synchronized void d(Intent intent) {
        if (this.c) {
            Message a2 = a(intent);
            if (this.f6699a.size() >= 50) {
                this.f6699a.remove(0);
            }
            this.f6699a.add(a2);
        } else if (this.f6696a == null) {
            this.f6693a.bindService(intent, new as(this), 1);
            this.c = true;
            this.f6699a.clear();
            this.f6699a.add(a(intent));
        } else {
            try {
                this.f6696a.send(a(intent));
            } catch (RemoteException unused) {
                this.f6696a = null;
                this.c = false;
            }
        }
    }

    /* renamed from: d  reason: collision with other method in class */
    private boolean m9075d() {
        if (m9079a()) {
            try {
                return this.f6693a.getPackageManager().getPackageInfo("com.xiaomi.xmsf", 4).versionCode >= 108;
            } catch (Exception unused) {
            }
        }
        return true;
    }

    private Intent e() {
        Intent intent = new Intent();
        String packageName = this.f6693a.getPackageName();
        g();
        intent.setComponent(new ComponentName(this.f6693a, "com.xiaomi.push.service.XMPushService"));
        intent.putExtra("mipush_app_package", packageName);
        return intent;
    }

    /* renamed from: e  reason: collision with other method in class */
    private boolean m9076e() {
        String packageName = this.f6693a.getPackageName();
        return packageName.contains("miui") || packageName.contains("xiaomi") || (this.f6693a.getApplicationInfo().flags & 1) != 0;
    }

    private void f() {
        try {
            PackageManager packageManager = this.f6693a.getPackageManager();
            ComponentName componentName = new ComponentName(this.f6693a, "com.xiaomi.push.service.XMPushService");
            if (packageManager.getComponentEnabledSetting(componentName) != 2) {
                packageManager.setComponentEnabledSetting(componentName, 2, 1);
            }
        } catch (Throwable unused) {
        }
    }

    private void g() {
        try {
            PackageManager packageManager = this.f6693a.getPackageManager();
            ComponentName componentName = new ComponentName(this.f6693a, "com.xiaomi.push.service.XMPushService");
            if (packageManager.getComponentEnabledSetting(componentName) != 1) {
                packageManager.setComponentEnabledSetting(componentName, 1, 1);
            }
        } catch (Throwable unused) {
        }
    }

    /* renamed from: a  reason: collision with other method in class */
    public void m9077a() {
        b(m9072a());
    }

    public void a(int i) {
        a(i, 0);
    }

    /* access modifiers changed from: package-private */
    public void a(int i, int i2) {
        Intent a2 = m9072a();
        a2.setAction("com.xiaomi.mipush.CLEAR_NOTIFICATION");
        a2.putExtra(bh.A, this.f6693a.getPackageName());
        a2.putExtra(bh.B, i);
        a2.putExtra(bh.C, i2);
        c(a2);
    }

    /* access modifiers changed from: package-private */
    public void a(int i, String str) {
        Intent a2 = m9072a();
        a2.setAction("com.xiaomi.mipush.thirdparty");
        a2.putExtra("com.xiaomi.mipush.thirdparty_LEVEL", i);
        a2.putExtra("com.xiaomi.mipush.thirdparty_DESC", str);
        b(a2);
    }

    /* access modifiers changed from: package-private */
    /* renamed from: a  reason: collision with other method in class */
    public void m9078a(Intent intent) {
        intent.fillIn(m9072a(), 24);
        c(intent);
    }

    public final void a(hn hnVar) {
        Intent a2 = m9072a();
        byte[] a3 = it.a(hnVar);
        if (a3 == null) {
            b.m9051a("send TinyData failed, because tinyDataBytes is null.");
            return;
        }
        a2.setAction("com.xiaomi.mipush.SEND_TINYDATA");
        a2.putExtra("mipush_payload", a3);
        b(a2);
    }

    public final void a(ij ijVar, boolean z) {
        ep.a(this.f6693a.getApplicationContext()).a(this.f6693a.getPackageName(), "E100003", ijVar.a(), AuthCode.StatusCode.WAITING_CONNECT, null);
        this.f6694a = null;
        b.m9086a(this.f6693a).f6707a = ijVar.a();
        Intent a2 = m9072a();
        byte[] a3 = it.a(ai.a(this.f6693a, ijVar, hj.Registration));
        if (a3 == null) {
            b.m9051a("register fail, because msgBytes is null.");
            return;
        }
        a2.setAction("com.xiaomi.mipush.REGISTER_APP");
        a2.putExtra("mipush_app_id", b.m9086a(this.f6693a).m9087a());
        a2.putExtra("mipush_payload", a3);
        a2.putExtra("mipush_session", this.f6698a);
        a2.putExtra("mipush_env_chanage", z);
        a2.putExtra("mipush_env_type", b.m9086a(this.f6693a).a());
        if (!bj.b(this.f6693a) || !m9082b()) {
            this.f6694a = a2;
        } else {
            c(a2);
        }
    }

    public final void a(ip ipVar) {
        byte[] a2 = it.a(ai.a(this.f6693a, ipVar, hj.UnRegistration));
        if (a2 == null) {
            b.m9051a("unregister fail, because msgBytes is null.");
            return;
        }
        Intent a3 = m9072a();
        a3.setAction("com.xiaomi.mipush.UNREGISTER_APP");
        a3.putExtra("mipush_app_id", b.m9086a(this.f6693a).m9087a());
        a3.putExtra("mipush_payload", a2);
        c(a3);
    }

    public final <T extends iu<T, ?>> void a(T t, hj hjVar, hw hwVar) {
        a(t, hjVar, !hjVar.equals(hj.Registration), hwVar);
    }

    public <T extends iu<T, ?>> void a(T t, hj hjVar, boolean z) {
        a aVar = new a();
        aVar.f6701a = t;
        aVar.a = hjVar;
        aVar.f6702a = z;
        synchronized (f6692a) {
            f6692a.add(aVar);
            if (f6692a.size() > 10) {
                f6692a.remove(0);
            }
        }
    }

    public final <T extends iu<T, ?>> void a(T t, hj hjVar, boolean z, hw hwVar) {
        a(t, hjVar, z, true, hwVar, true);
    }

    public final <T extends iu<T, ?>> void a(T t, hj hjVar, boolean z, hw hwVar, boolean z2) {
        a(t, hjVar, z, true, hwVar, z2);
    }

    public final <T extends iu<T, ?>> void a(T t, hj hjVar, boolean z, boolean z2, hw hwVar, boolean z3) {
        a(t, hjVar, z, z2, hwVar, z3, this.f6693a.getPackageName(), b.m9086a(this.f6693a).m9087a());
    }

    public final <T extends iu<T, ?>> void a(T t, hj hjVar, boolean z, boolean z2, hw hwVar, boolean z3, String str, String str2) {
        a(t, hjVar, z, z2, hwVar, z3, str, str2, true);
    }

    public final <T extends iu<T, ?>> void a(T t, hj hjVar, boolean z, boolean z2, hw hwVar, boolean z3, String str, String str2, boolean z4) {
        a(t, hjVar, z, z2, hwVar, z3, str, str2, z4, true);
    }

    public final <T extends iu<T, ?>> void a(T t, hj hjVar, boolean z, boolean z2, hw hwVar, boolean z3, String str, String str2, boolean z4, boolean z5) {
        if (!z5 || b.m9086a(this.f6693a).m9095c()) {
            Cif a2 = z4 ? ai.a(this.f6693a, t, hjVar, z, str, str2) : ai.b(this.f6693a, t, hjVar, z, str, str2);
            if (hwVar != null) {
                a2.a(hwVar);
            }
            byte[] a3 = it.a(a2);
            if (a3 == null) {
                b.m9051a("send message fail, because msgBytes is null.");
                return;
            }
            db.a(this.f6693a.getPackageName(), this.f6693a, t, hjVar, a3.length);
            Intent a4 = m9072a();
            a4.setAction("com.xiaomi.mipush.SEND_MESSAGE");
            a4.putExtra("mipush_payload", a3);
            a4.putExtra("com.xiaomi.mipush.MESSAGE_CACHE", z3);
            c(a4);
        } else if (z2) {
            a(t, hjVar, z);
        } else {
            b.m9051a("drop the message before initialization.");
        }
    }

    public final void a(String str, au auVar, e eVar) {
        af.a(this.f6693a).a(auVar, "syncing");
        a(str, auVar, false, i.m9104a(this.f6693a, eVar));
    }

    public void a(String str, String str2) {
        Intent a2 = m9072a();
        a2.setAction("com.xiaomi.mipush.CLEAR_NOTIFICATION");
        a2.putExtra(bh.A, this.f6693a.getPackageName());
        a2.putExtra(bh.G, str);
        a2.putExtra(bh.H, str2);
        c(a2);
    }

    public final void a(boolean z) {
        a(z, (String) null);
    }

    public final void a(boolean z, String str) {
        au auVar;
        if (z) {
            af.a(this.f6693a).a(au.DISABLE_PUSH, "syncing");
            af.a(this.f6693a).a(au.ENABLE_PUSH, "");
            auVar = au.DISABLE_PUSH;
        } else {
            af.a(this.f6693a).a(au.ENABLE_PUSH, "syncing");
            af.a(this.f6693a).a(au.DISABLE_PUSH, "");
            auVar = au.ENABLE_PUSH;
        }
        a(str, auVar, true, (HashMap<String, String>) null);
    }

    /* renamed from: a  reason: collision with other method in class */
    public boolean m9079a() {
        return this.f6700a && 1 == b.m9086a(this.f6693a).a();
    }

    /* renamed from: a  reason: collision with other method in class */
    public boolean m9080a(int i) {
        if (!b.m9086a(this.f6693a).m9093b()) {
            return false;
        }
        c(i);
        ii iiVar = new ii();
        iiVar.a(ba.a());
        iiVar.b(b.m9086a(this.f6693a).m9087a());
        iiVar.d(this.f6693a.getPackageName());
        iiVar.c(ht.ClientABTest.f7140a);
        iiVar.f7282a = new HashMap();
        iiVar.f7282a.put("boot_mode", String.valueOf(i));
        a(this.f6693a).a((iu) iiVar, hj.Notification, false, (hw) null);
        return true;
    }

    /* renamed from: b  reason: collision with other method in class */
    public final void m9081b() {
        Intent a2 = m9072a();
        a2.setAction("com.xiaomi.mipush.DISABLE_PUSH");
        c(a2);
    }

    public void b(int i) {
        Intent a2 = m9072a();
        a2.setAction("com.xiaomi.mipush.SET_NOTIFICATION_TYPE");
        a2.putExtra(bh.A, this.f6693a.getPackageName());
        a2.putExtra(bh.D, i);
        String str = bh.F;
        a2.putExtra(str, bo.b(this.f6693a.getPackageName() + i));
        c(a2);
    }

    /* renamed from: b  reason: collision with other method in class */
    public boolean m9082b() {
        if (!m9079a() || !m9076e()) {
            return true;
        }
        if (this.f6697a == null) {
            Integer valueOf = Integer.valueOf(bk.a(this.f6693a).a());
            this.f6697a = valueOf;
            if (valueOf.intValue() == 0) {
                this.f6693a.getContentResolver().registerContentObserver(bk.a(this.f6693a).m9701a(), false, new ar(this, new Handler(Looper.getMainLooper())));
            }
        }
        return this.f6697a.intValue() != 0;
    }

    /* renamed from: c  reason: collision with other method in class */
    public void m9083c() {
        Intent intent = this.f6694a;
        if (intent != null) {
            c(intent);
            this.f6694a = null;
        }
    }

    /* renamed from: d  reason: collision with other method in class */
    public void m9084d() {
        synchronized (f6692a) {
            boolean z = Thread.currentThread() == Looper.getMainLooper().getThread();
            Iterator<a> it = f6692a.iterator();
            while (it.hasNext()) {
                a next = it.next();
                a(next.f6701a, next.a, next.f6702a, false, null, true);
                if (!z) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException unused) {
                    }
                }
            }
            f6692a.clear();
        }
    }

    /* renamed from: e  reason: collision with other method in class */
    public void m9085e() {
        Intent a2 = m9072a();
        a2.setAction("com.xiaomi.mipush.SET_NOTIFICATION_TYPE");
        a2.putExtra(bh.A, this.f6693a.getPackageName());
        a2.putExtra(bh.F, bo.b(this.f6693a.getPackageName()));
        c(a2);
    }
}