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


package com.xiaomi.push.service;

import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.ContentObserver;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Messenger;
import android.os.Parcelable;
import android.os.Process;
import android.os.SystemClock;
import android.provider.Settings;
import android.text.TextUtils;
import com.huawei.hms.support.api.entity.auth.AuthCode;
import com.xiaomi.clientreport.data.Config;
import com.xiaomi.mipush.sdk.Constants;
import com.xiaomi.mipush.sdk.ErrorCode;
import com.xiaomi.push.Cif;
import com.xiaomi.push.ae;
import com.xiaomi.push.al;
import com.xiaomi.push.ar;
import com.xiaomi.push.bj;
import com.xiaomi.push.bo;
import com.xiaomi.push.bt;
import com.xiaomi.push.cv;
import com.xiaomi.push.dd;
import com.xiaomi.push.df;
import com.xiaomi.push.ee;
import com.xiaomi.push.eo;
import com.xiaomi.push.ep;
import com.xiaomi.push.ev;
import com.xiaomi.push.fe;
import com.xiaomi.push.fl;
import com.xiaomi.push.fp;
import com.xiaomi.push.fq;
import com.xiaomi.push.fs;
import com.xiaomi.push.fu;
import com.xiaomi.push.fv;
import com.xiaomi.push.ga;
import com.xiaomi.push.ge;
import com.xiaomi.push.gf;
import com.xiaomi.push.gg;
import com.xiaomi.push.gi;
import com.xiaomi.push.gu;
import com.xiaomi.push.hb;
import com.xiaomi.push.hd;
import com.xiaomi.push.he;
import com.xiaomi.push.hh;
import com.xiaomi.push.hj;
import com.xiaomi.push.hn;
import com.xiaomi.push.ho;
import com.xiaomi.push.ii;
import com.xiaomi.push.ij;
import com.xiaomi.push.it;
import com.xiaomi.push.iz;
import com.xiaomi.push.service.bd;
import com.xiaomi.push.service.n;
import com.xiaomi.push.v;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class XMPushService extends Service implements fs {
    private static boolean b = false;
    private int a = 0;

    /* renamed from: a  reason: collision with other field name */
    private long f7473a = 0;

    /* renamed from: a  reason: collision with other field name */
    private ContentObserver f7474a;

    /* renamed from: a  reason: collision with other field name */
    Messenger f7475a = null;

    /* renamed from: a  reason: collision with other field name */
    private fl f7476a;

    /* renamed from: a  reason: collision with other field name */
    private fp f7477a;

    /* renamed from: a  reason: collision with other field name */
    private fq f7478a;

    /* renamed from: a  reason: collision with other field name */
    private fu f7479a = new cf(this);

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

    /* renamed from: a  reason: collision with other field name */
    private f f7481a;

    /* renamed from: a  reason: collision with other field name */
    private k f7482a;

    /* renamed from: a  reason: collision with other field name */
    private r f7483a;

    /* renamed from: a  reason: collision with other field name */
    private t f7484a;

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

    /* renamed from: a  reason: collision with other field name */
    private bn f7486a;

    /* renamed from: a  reason: collision with other field name */
    private j f7487a;

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

    /* renamed from: a  reason: collision with other field name */
    protected Class f7489a = XMJobService.class;

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

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

    /* renamed from: a  reason: collision with other field name */
    private Collection<ao> f7492a = Collections.synchronizedCollection(new ArrayList());

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

    /* renamed from: b  reason: collision with other field name */
    private int f7494b = 0;

    /* renamed from: b  reason: collision with other field name */
    private ContentObserver f7495b;

    /* access modifiers changed from: private */
    public class a extends BroadcastReceiver {

        /* renamed from: a  reason: collision with other field name */
        private final Object f7496a;

        private a() {
            this.f7496a = new Object();
        }

        /* synthetic */ a(XMPushService xMPushService, cf cfVar) {
            this();
        }

        /* access modifiers changed from: private */
        /* access modifiers changed from: public */
        private void a() {
            if (Looper.myLooper() == Looper.getMainLooper()) {
                com.xiaomi.channel.commonutils.logger.b.d("[Alarm] Cannot perform lock.notifyAll in the UI thread!");
                return;
            }
            synchronized (this.f7496a) {
                try {
                    this.f7496a.notifyAll();
                } catch (Exception e) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("[Alarm] notify lock. " + e);
                }
            }
        }

        private void a(long j) {
            if (Looper.myLooper() == Looper.getMainLooper()) {
                com.xiaomi.channel.commonutils.logger.b.d("[Alarm] Cannot perform lock.wait in the UI thread!");
                return;
            }
            synchronized (this.f7496a) {
                try {
                    this.f7496a.wait(j);
                } catch (InterruptedException e) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("[Alarm] interrupt from waiting state. " + e);
                }
            }
        }

        public void onReceive(Context context, Intent intent) {
            long currentTimeMillis = System.currentTimeMillis();
            com.xiaomi.channel.commonutils.logger.b.c("[Alarm] heartbeat alarm has been triggered.");
            if (!bh.o.equals(intent.getAction())) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("[Alarm] cancel the old ping timer");
                ev.a();
            } else if (TextUtils.equals(context.getPackageName(), intent.getPackage())) {
                com.xiaomi.channel.commonutils.logger.b.c("[Alarm] Ping XMChannelService on timer");
                try {
                    Intent intent2 = new Intent(context, XMPushService.class);
                    intent2.putExtra("time_stamp", System.currentTimeMillis());
                    intent2.setAction("com.xiaomi.push.timer");
                    ServiceClient.getInstance(context).startServiceSafely(intent2);
                    a(3000);
                    com.xiaomi.channel.commonutils.logger.b.m9051a("[Alarm] heartbeat alarm finish in " + (System.currentTimeMillis() - currentTimeMillis));
                } catch (Throwable unused) {
                }
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class b extends j {

        /* renamed from: a  reason: collision with other field name */
        bd.b f7497a = null;

        public b(bd.b bVar) {
            super(9);
            this.f7497a = bVar;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "bind the client. " + this.f7497a.g;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9639a() {
            try {
                if (!XMPushService.this.m9637c()) {
                    com.xiaomi.channel.commonutils.logger.b.d("trying bind while the connection is not created, quit!");
                    return;
                }
                bd.b a2 = bd.a().a(this.f7497a.g, this.f7497a.f7564b);
                if (a2 == null) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("ignore bind because the channel " + this.f7497a.g + " is removed ");
                } else if (a2.f7559a == bd.c.unbind) {
                    a2.a(bd.c.binding, 0, 0, (String) null, (String) null);
                    XMPushService.this.f7477a.a(a2);
                    hd.a(XMPushService.this, a2);
                } else {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("trying duplicate bind, ingore! " + a2.f7559a);
                }
            } catch (Exception e) {
                com.xiaomi.channel.commonutils.logger.b.d("Meet error when trying to bind. " + e);
                XMPushService.this.a(10, e);
            } catch (Throwable unused) {
            }
        }
    }

    /* access modifiers changed from: package-private */
    public static class c extends j {
        private final bd.b a;

        public c(bd.b bVar) {
            super(12);
            this.a = bVar;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "bind time out. chid=" + this.a.g;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9640a() {
            this.a.a(bd.c.unbind, 1, 21, (String) null, (String) null);
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof c)) {
                return false;
            }
            return TextUtils.equals(((c) obj).a.g, this.a.g);
        }

        public int hashCode() {
            return this.a.g.hashCode();
        }
    }

    class d extends j {
        private fe a = null;

        public d(fe feVar) {
            super(8);
            this.a = feVar;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "receive a message.";
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9641a() {
            XMPushService.this.f7485a.a(this.a);
        }
    }

    public class e extends j {
        e() {
            super(1);
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "do reconnect..";
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9642a() {
            if (XMPushService.this.m9632a()) {
                XMPushService xMPushService = XMPushService.this;
                if (xMPushService.a((XMPushService) xMPushService.getApplicationContext())) {
                    XMPushService.this.f();
                    return;
                }
            }
            com.xiaomi.channel.commonutils.logger.b.m9051a("should not connect. quit the job.");
        }
    }

    /* access modifiers changed from: package-private */
    public class f extends BroadcastReceiver {
        f() {
        }

        public void onReceive(Context context, Intent intent) {
            com.xiaomi.channel.commonutils.logger.b.m9051a("network changed, " + com.xiaomi.push.l.a(intent));
            XMPushService.this.onStart(intent, 1);
        }
    }

    public class g extends j {

        /* renamed from: a  reason: collision with other field name */
        public Exception f7499a;
        public int b;

        g(int i, Exception exc) {
            super(2);
            this.b = i;
            this.f7499a = exc;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "disconnect the connection.";
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9643a() {
            XMPushService.this.a(this.b, this.f7499a);
        }
    }

    class h extends j {
        h() {
            super(65535);
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "Init Job";
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9644a() {
            XMPushService.this.c();
        }
    }

    /* access modifiers changed from: package-private */
    public class i extends j {
        private Intent a = null;

        public i(Intent intent) {
            super(15);
            this.a = intent;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "Handle intent action = " + this.a.getAction();
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9645a() {
            XMPushService.this.d(this.a);
        }
    }

    public static abstract class j extends n.b {
        public j(int i) {
            super(i);
        }

        public abstract String a();

        /* renamed from: a  reason: collision with other method in class */
        public abstract void m9646a();

        public void run() {
            if (!(this.a == 4 || this.a == 8)) {
                com.xiaomi.channel.commonutils.logger.b.m9052a(com.xiaomi.channel.commonutils.logger.a.a, a());
            }
            m9646a();
        }
    }

    class k extends BroadcastReceiver {
        k() {
        }

        public void onReceive(Context context, Intent intent) {
            com.xiaomi.channel.commonutils.logger.b.m9051a("[HB] hold short heartbeat, " + com.xiaomi.push.l.a(intent));
            if (intent != null && intent.getExtras() != null) {
                XMPushService.this.onStart(intent, 1);
            }
        }
    }

    class l extends j {
        public l() {
            super(5);
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "ask the job queue to quit";
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9647a() {
            XMPushService.this.f7488a.m9728a();
        }
    }

    class m extends j {
        private gg a = null;

        public m(gg ggVar) {
            super(8);
            this.a = ggVar;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "receive a message.";
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9648a() {
            XMPushService.this.f7485a.a(this.a);
        }
    }

    public interface n {
        void a();
    }

    /* access modifiers changed from: package-private */
    public class o extends j {

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

        public o(boolean z) {
            super(4);
            this.f7502a = z;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "send ping..";
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9649a() {
            if (XMPushService.this.m9637c()) {
                try {
                    if (!this.f7502a) {
                        hd.a();
                    }
                    XMPushService.this.f7477a.b(this.f7502a);
                } catch (ga e) {
                    com.xiaomi.channel.commonutils.logger.b.a(e);
                    XMPushService.this.a(10, e);
                }
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class p extends j {

        /* renamed from: a  reason: collision with other field name */
        bd.b f7503a = null;

        public p(bd.b bVar) {
            super(4);
            this.f7503a = bVar;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "rebind the client. " + this.f7503a.g;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9650a() {
            try {
                this.f7503a.a(bd.c.unbind, 1, 16, (String) null, (String) null);
                XMPushService.this.f7477a.a(this.f7503a.g, this.f7503a.f7564b);
                XMPushService.this.a(new b(this.f7503a), 300);
            } catch (ga e) {
                com.xiaomi.channel.commonutils.logger.b.a(e);
                XMPushService.this.a(10, e);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class q extends j {
        q() {
            super(3);
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "reset the connection.";
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9651a() {
            XMPushService.this.a(11, (Exception) null);
            if (XMPushService.this.m9632a()) {
                XMPushService xMPushService = XMPushService.this;
                if (xMPushService.a((XMPushService) xMPushService.getApplicationContext())) {
                    XMPushService.this.f();
                }
            }
        }
    }

    class r extends BroadcastReceiver {
        r() {
        }

        public void onReceive(Context context, Intent intent) {
            XMPushService.this.onStart(intent, 1);
        }
    }

    /* access modifiers changed from: package-private */
    public class s extends j {

        /* renamed from: a  reason: collision with other field name */
        bd.b f7504a = null;

        /* renamed from: a  reason: collision with other field name */
        String f7505a;
        int b;

        /* renamed from: b  reason: collision with other field name */
        String f7506b;

        public s(bd.b bVar, int i, String str, String str2) {
            super(9);
            this.f7504a = bVar;
            this.b = i;
            this.f7505a = str;
            this.f7506b = str2;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        public String a() {
            return "unbind the channel. " + this.f7504a.g;
        }

        @Override // com.xiaomi.push.service.XMPushService.j, com.xiaomi.push.service.XMPushService.j
        /* renamed from: a  reason: collision with other method in class */
        public void m9652a() {
            if (!(this.f7504a.f7559a == bd.c.unbind || XMPushService.this.f7477a == null)) {
                try {
                    XMPushService.this.f7477a.a(this.f7504a.g, this.f7504a.f7564b);
                } catch (ga e) {
                    com.xiaomi.channel.commonutils.logger.b.a(e);
                    XMPushService.this.a(10, e);
                }
            }
            this.f7504a.a(bd.c.unbind, this.b, 0, this.f7506b, this.f7505a);
        }
    }

    class t extends BroadcastReceiver {
        t() {
        }

        public void onReceive(Context context, Intent intent) {
            if (!XMPushService.this.f7493a) {
                XMPushService.this.f7493a = true;
            }
            com.xiaomi.channel.commonutils.logger.b.m9051a("[HB] wifi changed, " + com.xiaomi.push.l.a(intent));
            XMPushService.this.onStart(intent, 1);
        }
    }

    private gg a(gg ggVar, String str, String str2) {
        StringBuilder sb;
        bd a2 = bd.a();
        List<String> a3 = a2.m9693a(str);
        if (a3.isEmpty()) {
            sb = new StringBuilder("open channel should be called first before sending a packet, pkg=");
        } else {
            ggVar.o(str);
            str = ggVar.k();
            if (TextUtils.isEmpty(str)) {
                str = a3.get(0);
                ggVar.l(str);
            }
            bd.b a4 = a2.a(str, ggVar.m());
            if (!m9637c()) {
                sb = new StringBuilder("drop a packet as the channel is not connected, chid=");
            } else if (a4 == null || a4.f7559a != bd.c.binded) {
                sb = new StringBuilder("drop a packet as the channel is not opened, chid=");
            } else if (TextUtils.equals(str2, a4.i)) {
                return ggVar;
            } else {
                sb = new StringBuilder("invalid session. ");
                sb.append(str2);
                com.xiaomi.channel.commonutils.logger.b.m9051a(sb.toString());
                return null;
            }
        }
        sb.append(str);
        com.xiaomi.channel.commonutils.logger.b.m9051a(sb.toString());
        return null;
    }

    private bd.b a(String str, Intent intent) {
        bd.b a2 = bd.a().a(str, intent.getStringExtra(bh.p));
        if (a2 == null) {
            a2 = new bd.b(this);
        }
        a2.g = intent.getStringExtra(bh.s);
        a2.f7564b = intent.getStringExtra(bh.p);
        a2.c = intent.getStringExtra(bh.u);
        a2.f7561a = intent.getStringExtra(bh.A);
        a2.e = intent.getStringExtra(bh.y);
        a2.f = intent.getStringExtra(bh.z);
        a2.f7563a = intent.getBooleanExtra(bh.x, false);
        a2.h = intent.getStringExtra(bh.w);
        a2.i = intent.getStringExtra(bh.E);
        a2.d = intent.getStringExtra(bh.v);
        a2.f7560a = this.f7487a;
        a2.a((Messenger) intent.getParcelableExtra(bh.I));
        a2.f7553a = getApplicationContext();
        bd.a().a(a2);
        return a2;
    }

    private String a() {
        String a2 = com.xiaomi.push.l.m9606a("ro.miui.region");
        return TextUtils.isEmpty(a2) ? com.xiaomi.push.l.m9606a("ro.product.locale.region") : a2;
    }

    private void a(BroadcastReceiver broadcastReceiver) {
        if (broadcastReceiver != null) {
            try {
                unregisterReceiver(broadcastReceiver);
            } catch (IllegalArgumentException e2) {
                com.xiaomi.channel.commonutils.logger.b.a(e2);
            }
        }
    }

    private void a(Intent intent) {
        Bundle extras;
        if (intent != null && (extras = intent.getExtras()) != null) {
            m.a(getApplicationContext()).m9724a(extras.getString("digest"));
        }
    }

    private void a(Intent intent, int i2) {
        byte[] byteArrayExtra = intent.getByteArrayExtra("mipush_payload");
        boolean booleanExtra = intent.getBooleanExtra("com.xiaomi.mipush.MESSAGE_CACHE", true);
        ii iiVar = new ii();
        try {
            it.a(iiVar, byteArrayExtra);
            al.a(getApplicationContext()).a((al.a) new b(iiVar, new WeakReference(this), booleanExtra), i2);
        } catch (iz unused) {
            com.xiaomi.channel.commonutils.logger.b.d("aw_ping : send help app ping  error");
        }
    }

    private void a(a aVar) {
        if (aVar == null || !TextUtils.isEmpty(aVar.b()) || TextUtils.isEmpty(aVar.a())) {
            com.xiaomi.channel.commonutils.logger.b.b("no need to check country code");
            return;
        }
        String a2 = "com.xiaomi.xmsf".equals(getPackageName()) ? a() : com.xiaomi.push.l.b();
        if (!TextUtils.isEmpty(a2)) {
            String name = com.xiaomi.push.l.a(a2).name();
            if (TextUtils.equals(name, aVar.a())) {
                aVar.b(a2);
                com.xiaomi.channel.commonutils.logger.b.m9051a("update country code");
                return;
            }
            com.xiaomi.channel.commonutils.logger.b.m9051a("not update country code, because not equals " + name);
            return;
        }
        com.xiaomi.channel.commonutils.logger.b.b("check no country code");
    }

    private static void a(String str) {
        if (com.xiaomi.push.q.China.name().equals(str)) {
            cv.a("cn.app.chat.xiaomi.net", "cn.app.chat.xiaomi.net");
            cv.a("cn.app.chat.xiaomi.net", "111.13.141.211:443");
            cv.a("cn.app.chat.xiaomi.net", "39.156.81.172:443");
            cv.a("cn.app.chat.xiaomi.net", "111.202.1.250:443");
            cv.a("cn.app.chat.xiaomi.net", "123.125.102.213:443");
            cv.a("resolver.msg.xiaomi.net", "111.13.142.153:443");
            cv.a("resolver.msg.xiaomi.net", "111.202.1.252:443");
        } else if (com.xiaomi.push.q.Global.name().equals(str)) {
            cv.a("app.chat.global.xiaomi.net", "app.chat.global.xiaomi.net");
            cv.a("resolver.msg.global.xiaomi.net", "161.117.97.14:443");
            cv.a("resolver.msg.global.xiaomi.net", "161.117.180.178:443");
        } else if (com.xiaomi.push.q.Europe.name().equals(str)) {
            cv.a("fr.app.chat.global.xiaomi.net", "fr.app.chat.global.xiaomi.net");
            cv.a("resolver.msg.global.xiaomi.net", "161.117.97.14:443");
            cv.a("resolver.msg.global.xiaomi.net", "161.117.180.178:443");
        } else if (com.xiaomi.push.q.Russia.name().equals(str)) {
            cv.a("ru.app.chat.global.xiaomi.net", "ru.app.chat.global.xiaomi.net");
            cv.a("resolver.msg.global.xiaomi.net", "161.117.97.14:443");
            cv.a("resolver.msg.global.xiaomi.net", "161.117.180.178:443");
        } else if (com.xiaomi.push.q.India.name().equals(str)) {
            cv.a("ru.app.chat.global.xiaomi.net", "idmb.app.chat.global.xiaomi.net");
            cv.a("resolver.msg.global.xiaomi.net", "161.117.97.14:443");
            cv.a("resolver.msg.global.xiaomi.net", "161.117.180.178:443");
        }
    }

    private void a(String str, int i2) {
        Collection<bd.b> a2 = bd.a().m9692a(str);
        if (a2 != null) {
            for (bd.b bVar : a2) {
                if (bVar != null) {
                    a(new s(bVar, i2, null, null));
                }
            }
        }
        bd.a().m9695a(str);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean a(Context context) {
        try {
            ar.a();
            for (int i2 = 100; i2 > 0; i2--) {
                if (bj.c(context)) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("network connectivity ok.");
                    return true;
                }
                try {
                    Thread.sleep(100);
                } catch (Exception unused) {
                }
            }
            return false;
        } catch (Exception unused2) {
            return true;
        }
    }

    /* renamed from: a  reason: collision with other method in class */
    private boolean m9622a(String str, Intent intent) {
        bd.b a2 = bd.a().a(str, intent.getStringExtra(bh.p));
        boolean z = false;
        if (a2 == null || str == null) {
            return false;
        }
        String stringExtra = intent.getStringExtra(bh.E);
        String stringExtra2 = intent.getStringExtra(bh.w);
        if (!TextUtils.isEmpty(a2.i) && !TextUtils.equals(stringExtra, a2.i)) {
            com.xiaomi.channel.commonutils.logger.b.m9051a("session changed. old session=" + a2.i + ", new session=" + stringExtra + " chid = " + str);
            z = true;
        }
        if (stringExtra2.equals(a2.h)) {
            return z;
        }
        com.xiaomi.channel.commonutils.logger.b.m9051a("security changed. chid = " + str + " sechash = " + bo.a(stringExtra2));
        return true;
    }

    /* renamed from: a  reason: collision with other method in class */
    private int[] m9623a() {
        String[] split;
        String a2 = ax.a(getApplicationContext()).a(ho.FallDownTimeRange.a(), "");
        if (!TextUtils.isEmpty(a2) && (split = a2.split(Constants.ACCEPT_TIME_SEPARATOR_SP)) != null && split.length >= 2) {
            int[] iArr = new int[2];
            try {
                iArr[0] = Integer.valueOf(split[0]).intValue();
                iArr[1] = Integer.valueOf(split[1]).intValue();
                if (iArr[0] < 0 || iArr[0] > 23 || iArr[1] < 0 || iArr[1] > 23 || iArr[0] == iArr[1]) {
                    return null;
                }
                return iArr;
            } catch (NumberFormatException e2) {
                com.xiaomi.channel.commonutils.logger.b.d("parse falldown time range failure: " + e2);
            }
        }
        return null;
    }

    private String b() {
        String str;
        ar.a();
        long elapsedRealtime = SystemClock.elapsedRealtime();
        Object obj = new Object();
        String str2 = null;
        if ("com.xiaomi.xmsf".equals(getPackageName())) {
            bk a2 = bk.a(this);
            str = null;
            while (true) {
                if (!TextUtils.isEmpty(str) && a2.a() != 0) {
                    break;
                }
                if (TextUtils.isEmpty(str)) {
                    str = a();
                }
                try {
                    synchronized (obj) {
                        obj.wait(100);
                    }
                } catch (InterruptedException unused) {
                }
            }
        } else {
            str = com.xiaomi.push.l.b();
        }
        if (!TextUtils.isEmpty(str)) {
            a.a(getApplicationContext()).b(str);
            str2 = com.xiaomi.push.l.a(str).name();
        }
        com.xiaomi.channel.commonutils.logger.b.m9051a("wait region :" + str2 + " cost = " + (SystemClock.elapsedRealtime() - elapsedRealtime));
        return str2;
    }

    private void b(Intent intent) {
        long j2;
        String stringExtra = intent.getStringExtra(bh.A);
        String stringExtra2 = intent.getStringExtra(bh.E);
        Bundle bundleExtra = intent.getBundleExtra("ext_packet");
        bd a2 = bd.a();
        fe feVar = null;
        if (bundleExtra != null) {
            gf gfVar = (gf) a(new gf(bundleExtra), stringExtra, stringExtra2);
            if (gfVar != null) {
                feVar = fe.a(gfVar, a2.a(gfVar.k(), gfVar.m()).h);
            } else {
                return;
            }
        } else {
            byte[] byteArrayExtra = intent.getByteArrayExtra("ext_raw_packet");
            if (byteArrayExtra != null) {
                try {
                    j2 = Long.parseLong(intent.getStringExtra(bh.p));
                } catch (NumberFormatException unused) {
                    j2 = 0;
                }
                String stringExtra3 = intent.getStringExtra(bh.q);
                String stringExtra4 = intent.getStringExtra(bh.r);
                String stringExtra5 = intent.getStringExtra("ext_chid");
                bd.b a3 = a2.a(stringExtra5, String.valueOf(j2));
                if (a3 != null) {
                    fe feVar2 = new fe();
                    try {
                        feVar2.a(Integer.parseInt(stringExtra5));
                    } catch (NumberFormatException unused2) {
                    }
                    feVar2.a("SECMSG", (String) null);
                    if (TextUtils.isEmpty(stringExtra3)) {
                        stringExtra3 = "xiaomi.com";
                    }
                    feVar2.a(j2, stringExtra3, stringExtra4);
                    feVar2.a(intent.getStringExtra("ext_pkt_id"));
                    feVar2.a(byteArrayExtra, a3.h);
                    com.xiaomi.channel.commonutils.logger.b.m9051a("send a message: chid=" + stringExtra5 + ", packetId=" + intent.getStringExtra("ext_pkt_id"));
                    feVar = feVar2;
                }
            }
        }
        if (feVar != null) {
            c(new bq(this, feVar));
        }
    }

    private void b(boolean z) {
        this.f7473a = SystemClock.elapsedRealtime();
        if (!m9637c()) {
            a(true);
        } else if (bj.b(this)) {
            c(new o(z));
        } else {
            c(new g(17, null));
            a(true);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void c() {
        String str;
        a a2 = a.a(getApplicationContext());
        String a3 = a2.a();
        com.xiaomi.channel.commonutils.logger.b.m9051a("region of cache is " + a3);
        if (TextUtils.isEmpty(a3)) {
            a3 = b();
        } else {
            a(a2);
        }
        if (!TextUtils.isEmpty(a3)) {
            this.f7490a = a3;
            a2.a(a3);
            if (com.xiaomi.push.q.Global.name().equals(this.f7490a)) {
                str = "app.chat.global.xiaomi.net";
            } else if (com.xiaomi.push.q.Europe.name().equals(this.f7490a)) {
                str = "fr.app.chat.global.xiaomi.net";
            } else if (com.xiaomi.push.q.Russia.name().equals(this.f7490a)) {
                str = "ru.app.chat.global.xiaomi.net";
            } else if (com.xiaomi.push.q.India.name().equals(this.f7490a)) {
                str = "idmb.app.chat.global.xiaomi.net";
            }
            fq.a(str);
        } else {
            this.f7490a = com.xiaomi.push.q.China.name();
        }
        if (com.xiaomi.push.q.China.name().equals(this.f7490a)) {
            fq.a("cn.app.chat.xiaomi.net");
        }
        a(this.f7490a);
        if (m9628i()) {
            cr crVar = new cr(this, 11);
            a(crVar);
            s.a(new cs(this, crVar));
        }
        try {
            if (v.m9752a()) {
                this.f7487a.a(this);
            }
        } catch (Exception e2) {
            com.xiaomi.channel.commonutils.logger.b.a(e2);
        }
    }

    private void c(Intent intent) {
        String stringExtra = intent.getStringExtra(bh.A);
        String stringExtra2 = intent.getStringExtra(bh.E);
        Parcelable[] parcelableArrayExtra = intent.getParcelableArrayExtra("ext_packets");
        int length = parcelableArrayExtra.length;
        gg[] ggVarArr = new gf[length];
        intent.getBooleanExtra("ext_encrypt", true);
        for (int i2 = 0; i2 < parcelableArrayExtra.length; i2++) {
            ggVarArr[i2] = new gf((Bundle) parcelableArrayExtra[i2]);
            ggVarArr[i2] = (gf) a(ggVarArr[i2], stringExtra, stringExtra2);
            if (ggVarArr[i2] == null) {
                return;
            }
        }
        bd a2 = bd.a();
        fe[] feVarArr = new fe[length];
        for (int i3 = 0; i3 < length; i3++) {
            gf gfVar = ggVarArr[i3];
            feVarArr[i3] = fe.a(gfVar, a2.a(gfVar.k(), gfVar.m()).h);
        }
        c(new c(this, feVarArr));
    }

    private void c(j jVar) {
        this.f7488a.a(jVar);
    }

    private void c(boolean z) {
        try {
            if (!v.m9752a()) {
                return;
            }
            if (z) {
                sendBroadcast(new Intent("miui.intent.action.NETWORK_CONNECTED"));
                for (ao aoVar : (ao[]) this.f7492a.toArray(new ao[0])) {
                    aoVar.a();
                }
                return;
            }
            sendBroadcast(new Intent("miui.intent.action.NETWORK_BLOCKED"));
        } catch (Exception e2) {
            com.xiaomi.channel.commonutils.logger.b.a(e2);
        }
    }

    private void d() {
        NetworkInfo networkInfo;
        try {
            networkInfo = ((ConnectivityManager) getSystemService("connectivity")).getActiveNetworkInfo();
        } catch (Exception e2) {
            com.xiaomi.channel.commonutils.logger.b.a(e2);
            networkInfo = null;
        }
        m.a(getApplicationContext()).a(networkInfo);
        if (networkInfo != null) {
            StringBuilder sb = new StringBuilder("network changed,");
            sb.append("[" + "type: " + networkInfo.getTypeName() + "[" + networkInfo.getSubtypeName() + "], state: " + networkInfo.getState() + "/" + networkInfo.getDetailedState());
            com.xiaomi.channel.commonutils.logger.b.m9051a(sb.toString());
            NetworkInfo.State state = networkInfo.getState();
            if (state == NetworkInfo.State.SUSPENDED || state == NetworkInfo.State.UNKNOWN) {
                return;
            }
        } else {
            com.xiaomi.channel.commonutils.logger.b.m9051a("network changed, no active network");
        }
        if (hb.a() != null) {
            hb.a().m9412a();
        }
        gu.m9408a((Context) this);
        this.f7476a.d();
        if (bj.b(this)) {
            if (m9637c() && m9625f()) {
                b(false);
            }
            if (!m9637c() && !m9638d()) {
                this.f7488a.a(1);
                a(new e());
            }
            df.a(this).a();
        } else {
            a(new g(2, null));
        }
        e();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Removed duplicated region for block: B:154:0x03f6  */
    /* JADX WARNING: Removed duplicated region for block: B:165:0x044b  */
    /* JADX WARNING: Removed duplicated region for block: B:372:? A[RETURN, SYNTHETIC] */
    private void d(Intent intent) {
        int i2;
        String str;
        SharedPreferences sharedPreferences;
        Object th;
        bd a2 = bd.a();
        boolean z = true;
        boolean z2 = false;
        int i3 = 0;
        if (bh.d.equalsIgnoreCase(intent.getAction()) || bh.j.equalsIgnoreCase(intent.getAction())) {
            String stringExtra = intent.getStringExtra(bh.s);
            if (TextUtils.isEmpty(intent.getStringExtra(bh.w))) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("security is empty. ignore.");
            } else if (!TextUtils.isEmpty(stringExtra)) {
                boolean a3 = m9622a(stringExtra, intent);
                bd.b a4 = a(stringExtra, intent);
                if (!bj.c(this)) {
                    this.f7487a.a(this, a4, false, 2, null);
                } else if (!m9637c()) {
                    a(true);
                } else if (a4.f7559a == bd.c.unbind) {
                    c(new b(a4));
                } else if (a3) {
                    c(new p(a4));
                } else if (a4.f7559a == bd.c.binding) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a(String.format("the client is binding. %1$s %2$s.", a4.g, bd.b.a(a4.f7564b)));
                } else if (a4.f7559a == bd.c.binded) {
                    this.f7487a.a(this, a4, true, 0, null);
                }
            } else {
                com.xiaomi.channel.commonutils.logger.b.d("channel id is empty, do nothing!");
            }
        } else if (bh.i.equalsIgnoreCase(intent.getAction())) {
            String stringExtra2 = intent.getStringExtra(bh.A);
            String stringExtra3 = intent.getStringExtra(bh.s);
            String stringExtra4 = intent.getStringExtra(bh.p);
            com.xiaomi.channel.commonutils.logger.b.m9051a("Service called close channel chid = " + stringExtra3 + " res = " + bd.b.a(stringExtra4));
            if (TextUtils.isEmpty(stringExtra3)) {
                for (String str2 : a2.m9693a(stringExtra2)) {
                    a(str2, 2);
                }
            } else if (TextUtils.isEmpty(stringExtra4)) {
                a(stringExtra3, 2);
            } else {
                a(stringExtra3, stringExtra4, 2, null, null);
            }
        } else if (bh.e.equalsIgnoreCase(intent.getAction())) {
            b(intent);
        } else if (bh.g.equalsIgnoreCase(intent.getAction())) {
            c(intent);
        } else if (bh.f.equalsIgnoreCase(intent.getAction())) {
            gg a5 = a(new ge(intent.getBundleExtra("ext_packet")), intent.getStringExtra(bh.A), intent.getStringExtra(bh.E));
            if (a5 != null) {
                c(new bq(this, fe.a(a5, a2.a(a5.k(), a5.m()).h)));
            }
        } else if (bh.h.equalsIgnoreCase(intent.getAction())) {
            gg a6 = a(new gi(intent.getBundleExtra("ext_packet")), intent.getStringExtra(bh.A), intent.getStringExtra(bh.E));
            if (a6 != null) {
                c(new bq(this, fe.a(a6, a2.a(a6.k(), a6.m()).h)));
            }
        } else if (bh.k.equals(intent.getAction())) {
            String stringExtra5 = intent.getStringExtra(bh.s);
            String stringExtra6 = intent.getStringExtra(bh.p);
            if (stringExtra5 != null) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("request reset connection from chid = " + stringExtra5);
                bd.b a7 = bd.a().a(stringExtra5, stringExtra6);
                if (a7 != null && a7.h.equals(intent.getStringExtra(bh.w)) && a7.f7559a == bd.c.binded) {
                    fp a8 = m9629a();
                    if (a8 == null || !a8.a(SystemClock.elapsedRealtime() - 15000)) {
                        c(new q());
                    }
                }
            }
        } else {
            String str3 = null;
            r2 = null;
            bd.b bVar = null;
            str3 = null;
            if (bh.l.equals(intent.getAction())) {
                String stringExtra7 = intent.getStringExtra(bh.A);
                List<String> a9 = a2.m9693a(stringExtra7);
                if (a9.isEmpty()) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("open channel should be called first before update info, pkg=" + stringExtra7);
                    return;
                }
                String stringExtra8 = intent.getStringExtra(bh.s);
                String stringExtra9 = intent.getStringExtra(bh.p);
                if (TextUtils.isEmpty(stringExtra8)) {
                    stringExtra8 = a9.get(0);
                }
                if (TextUtils.isEmpty(stringExtra9)) {
                    Collection<bd.b> a10 = a2.m9692a(stringExtra8);
                    if (a10 != null && !a10.isEmpty()) {
                        bVar = a10.iterator().next();
                    }
                } else {
                    bVar = a2.a(stringExtra8, stringExtra9);
                }
                if (bVar != null) {
                    if (intent.hasExtra(bh.y)) {
                        bVar.e = intent.getStringExtra(bh.y);
                    }
                    if (intent.hasExtra(bh.z)) {
                        bVar.f = intent.getStringExtra(bh.z);
                    }
                }
            } else if ("android.intent.action.SCREEN_ON".equals(intent.getAction()) || "android.intent.action.SCREEN_OFF".equals(intent.getAction())) {
                if ("android.intent.action.SCREEN_ON".equals(intent.getAction())) {
                    if (!j()) {
                        com.xiaomi.channel.commonutils.logger.b.m9051a("exit falldown mode, activate alarm.");
                        e();
                        if (!(m9637c() || m9638d())) {
                            a(true);
                        }
                    }
                } else if ("android.intent.action.SCREEN_OFF".equals(intent.getAction()) && j() && ev.m9336a()) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("enter falldown mode, stop alarm.");
                    ev.a();
                }
            } else if ("com.xiaomi.mipush.REGISTER_APP".equals(intent.getAction())) {
                if (!bk.a(getApplicationContext()).m9702a() || bk.a(getApplicationContext()).a() != 0) {
                    byte[] byteArrayExtra = intent.getByteArrayExtra("mipush_payload");
                    String stringExtra10 = intent.getStringExtra("mipush_app_package");
                    boolean booleanExtra = intent.getBooleanExtra("mipush_env_chanage", false);
                    int intExtra = intent.getIntExtra("mipush_env_type", 1);
                    t.a(this).d(stringExtra10);
                    if (!booleanExtra || "com.xiaomi.xmsf".equals(getPackageName())) {
                        a(byteArrayExtra, stringExtra10);
                    } else {
                        c(new cg(this, 14, intExtra, stringExtra10, byteArrayExtra));
                    }
                } else {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("register without being provisioned. " + intent.getStringExtra("mipush_app_package"));
                }
            } else if ("com.xiaomi.mipush.SEND_MESSAGE".equals(intent.getAction()) || "com.xiaomi.mipush.UNREGISTER_APP".equals(intent.getAction())) {
                String stringExtra11 = intent.getStringExtra("mipush_app_package");
                byte[] byteArrayExtra2 = intent.getByteArrayExtra("mipush_payload");
                boolean booleanExtra2 = intent.getBooleanExtra("com.xiaomi.mipush.MESSAGE_CACHE", true);
                if ("com.xiaomi.mipush.UNREGISTER_APP".equals(intent.getAction())) {
                    t.a(this).a(stringExtra11);
                    if (com.xiaomi.push.l.m9609a(getApplicationContext())) {
                        ae.a(stringExtra11);
                    }
                }
                a(stringExtra11, byteArrayExtra2, booleanExtra2);
            } else if (bl.a.equals(intent.getAction())) {
                String stringExtra12 = intent.getStringExtra("uninstall_pkg_name");
                if (stringExtra12 != null && !TextUtils.isEmpty(stringExtra12.trim())) {
                    try {
                        PackageInfo packageInfo = getPackageManager().getPackageInfo(stringExtra12, 0);
                        if (packageInfo == null || packageInfo.applicationInfo == null || !com.xiaomi.push.i.m9474a(packageInfo.applicationInfo.uid)) {
                            z = false;
                        } else {
                            com.xiaomi.channel.commonutils.logger.b.m9051a("xspace's app fake uninstalled " + stringExtra12);
                        }
                    } catch (PackageManager.NameNotFoundException unused) {
                    }
                    if (!"com.xiaomi.channel".equals(stringExtra12) || bd.a().m9692a("1").isEmpty() || !z) {
                        SharedPreferences sharedPreferences2 = getSharedPreferences("pref_registered_pkg_names", 0);
                        String string = sharedPreferences2.getString(stringExtra12, null);
                        if (!TextUtils.isEmpty(string) && z) {
                            SharedPreferences.Editor edit = sharedPreferences2.edit();
                            edit.remove(stringExtra12);
                            edit.commit();
                            if (aj.m9668b((Context) this, stringExtra12)) {
                                aj.m9667b((Context) this, stringExtra12);
                            }
                            aj.m9663a((Context) this, stringExtra12);
                            aq.a(getApplicationContext(), stringExtra12);
                            if (m9637c() && string != null) {
                                try {
                                    af.a(this, af.a(stringExtra12, string));
                                    com.xiaomi.channel.commonutils.logger.b.m9051a("uninstall " + stringExtra12 + " msg sent");
                                } catch (ga e2) {
                                    com.xiaomi.channel.commonutils.logger.b.d("Fail to send Message: " + e2.getMessage());
                                    a(10, e2);
                                }
                            }
                        }
                    } else {
                        a("1", 0);
                        com.xiaomi.channel.commonutils.logger.b.m9051a("close the miliao channel as the app is uninstalled.");
                    }
                }
            } else if (bl.b.equals(intent.getAction())) {
                String stringExtra13 = intent.getStringExtra("data_cleared_pkg_name");
                if (!TextUtils.isEmpty(stringExtra13)) {
                    try {
                        sharedPreferences = getSharedPreferences("pref_registered_pkg_names", 0);
                        if (sharedPreferences != null) {
                            try {
                                str3 = sharedPreferences.getString(stringExtra13, null);
                            } catch (Throwable th2) {
                                th = th2;
                                com.xiaomi.channel.commonutils.logger.b.m9051a("Fail to get sp or appId : " + th);
                                if (!TextUtils.isEmpty(str3)) {
                                }
                                aq.a((Context) this, stringExtra13);
                                if (com.xiaomi.push.l.m9609a(getApplicationContext())) {
                                }
                            }
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        sharedPreferences = null;
                        com.xiaomi.channel.commonutils.logger.b.m9051a("Fail to get sp or appId : " + th);
                        if (!TextUtils.isEmpty(str3)) {
                        }
                        aq.a((Context) this, stringExtra13);
                        if (com.xiaomi.push.l.m9609a(getApplicationContext())) {
                        }
                    }
                    if (!TextUtils.isEmpty(str3)) {
                        SharedPreferences.Editor edit2 = sharedPreferences.edit();
                        edit2.remove(stringExtra13);
                        edit2.commit();
                        if (aj.m9668b((Context) this, stringExtra13)) {
                            aj.m9667b((Context) this, stringExtra13);
                        }
                        aj.m9663a((Context) this, stringExtra13);
                        if (m9637c()) {
                            try {
                                af.a(this, af.b(stringExtra13, str3));
                                com.xiaomi.channel.commonutils.logger.b.m9051a("send app data cleared Message pkgName is : " + stringExtra13);
                            } catch (ga e3) {
                                com.xiaomi.channel.commonutils.logger.b.d("Fail to send Message: " + e3);
                                a(10, e3);
                            }
                        }
                    }
                    aq.a((Context) this, stringExtra13);
                    if (com.xiaomi.push.l.m9609a(getApplicationContext())) {
                        ae.a(stringExtra13);
                    }
                }
            } else if ("com.xiaomi.mipush.CLEAR_NOTIFICATION".equals(intent.getAction())) {
                String stringExtra14 = intent.getStringExtra(bh.A);
                int intExtra2 = intent.getIntExtra(bh.B, -2);
                if (TextUtils.isEmpty(stringExtra14)) {
                    return;
                }
                if (intExtra2 >= -1) {
                    aj.a(this, stringExtra14, intExtra2, intent.getIntExtra(bh.C, -1));
                } else {
                    aj.a(this, stringExtra14, intent.getStringExtra(bh.G), intent.getStringExtra(bh.H));
                }
            } else if ("com.xiaomi.mipush.SET_NOTIFICATION_TYPE".equals(intent.getAction())) {
                String stringExtra15 = intent.getStringExtra(bh.A);
                String stringExtra16 = intent.getStringExtra(bh.F);
                if (intent.hasExtra(bh.D)) {
                    int intExtra3 = intent.getIntExtra(bh.D, 0);
                    str = bo.b(stringExtra15 + intExtra3);
                    i3 = intExtra3;
                    z = false;
                } else {
                    str = bo.b(stringExtra15);
                }
                if (TextUtils.isEmpty(stringExtra15) || !TextUtils.equals(stringExtra16, str)) {
                    com.xiaomi.channel.commonutils.logger.b.d("invalid notification for " + stringExtra15);
                } else if (z) {
                    aj.m9667b((Context) this, stringExtra15);
                } else {
                    aj.b(this, stringExtra15, i3);
                }
            } else if ("com.xiaomi.mipush.DISABLE_PUSH".equals(intent.getAction())) {
                String stringExtra17 = intent.getStringExtra("mipush_app_package");
                if (!TextUtils.isEmpty(stringExtra17)) {
                    t.a(this).b(stringExtra17);
                }
                if (!"com.xiaomi.xmsf".equals(getPackageName())) {
                    a(19, (Exception) null);
                    e();
                    stopSelf();
                }
            } else if ("com.xiaomi.mipush.DISABLE_PUSH_MESSAGE".equals(intent.getAction()) || "com.xiaomi.mipush.ENABLE_PUSH_MESSAGE".equals(intent.getAction())) {
                String stringExtra18 = intent.getStringExtra("mipush_app_package");
                byte[] byteArrayExtra3 = intent.getByteArrayExtra("mipush_payload");
                String stringExtra19 = intent.getStringExtra("mipush_app_id");
                String stringExtra20 = intent.getStringExtra("mipush_app_token");
                if ("com.xiaomi.mipush.DISABLE_PUSH_MESSAGE".equals(intent.getAction())) {
                    t.a(this).c(stringExtra18);
                }
                if ("com.xiaomi.mipush.ENABLE_PUSH_MESSAGE".equals(intent.getAction())) {
                    t.a(this).e(stringExtra18);
                    t.a(this).f(stringExtra18);
                }
                if (byteArrayExtra3 == null) {
                    v.a(this, stringExtra18, byteArrayExtra3, ErrorCode.ERROR_INVALID_PAYLOAD, "null payload");
                    return;
                }
                v.b(stringExtra18, byteArrayExtra3);
                a(new u(this, stringExtra18, stringExtra19, stringExtra20, byteArrayExtra3));
                if ("com.xiaomi.mipush.ENABLE_PUSH_MESSAGE".equals(intent.getAction()) && this.f7481a == null) {
                    this.f7481a = new f();
                    registerReceiver(this.f7481a, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
                }
            } else if ("com.xiaomi.mipush.SEND_TINYDATA".equals(intent.getAction())) {
                String stringExtra21 = intent.getStringExtra("mipush_app_package");
                byte[] byteArrayExtra4 = intent.getByteArrayExtra("mipush_payload");
                hn hnVar = new hn();
                try {
                    it.a(hnVar, byteArrayExtra4);
                    hh.a(this).a(hnVar, stringExtra21);
                } catch (iz e4) {
                    com.xiaomi.channel.commonutils.logger.b.a(e4);
                }
            } else if ("com.xiaomi.push.timer".equalsIgnoreCase(intent.getAction())) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("[Alarm] Service called on timer");
                if (!j()) {
                    ev.a(false);
                    if (m9625f()) {
                        b(false);
                    }
                } else if (ev.m9336a()) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("enter falldown mode, stop alarm");
                    ev.a();
                }
                a aVar = this.f7480a;
                if (aVar != null) {
                    aVar.a();
                }
            } else if ("com.xiaomi.push.check_alive".equalsIgnoreCase(intent.getAction())) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("Service called on check alive.");
                if (m9625f()) {
                    b(false);
                }
            } else if ("com.xiaomi.mipush.thirdparty".equals(intent.getAction())) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("on thirdpart push :" + intent.getStringExtra("com.xiaomi.mipush.thirdparty_DESC"));
                ev.a(this, intent.getIntExtra("com.xiaomi.mipush.thirdparty_LEVEL", 0));
            } else if ("android.net.conn.CONNECTIVITY_CHANGE".equals(intent.getAction())) {
                d();
            } else if ("miui.net.wifi.DIGEST_INFORMATION_CHANGED".equals(intent.getAction())) {
                a(intent);
            } else if ("com.xiaomi.xmsf.USE_INTELLIGENT_HB".equals(intent.getAction())) {
                if (intent.getExtras() != null && (i2 = intent.getExtras().getInt("effectivePeriod", 0)) > 0 && i2 <= 604800) {
                    m.a(getApplicationContext()).a(i2);
                }
            } else if ("action_cr_config".equals(intent.getAction())) {
                boolean booleanExtra3 = intent.getBooleanExtra("action_cr_event_switch", false);
                long longExtra = intent.getLongExtra("action_cr_event_frequency", 86400);
                boolean booleanExtra4 = intent.getBooleanExtra("action_cr_perf_switch", false);
                long longExtra2 = intent.getLongExtra("action_cr_perf_frequency", 86400);
                boolean booleanExtra5 = intent.getBooleanExtra("action_cr_event_en", true);
                long longExtra3 = intent.getLongExtra("action_cr_max_file_size", Config.DEFAULT_MAX_FILE_LENGTH);
                Config build = Config.getBuilder().setEventUploadSwitchOpen(booleanExtra3).setEventUploadFrequency(longExtra).setPerfUploadSwitchOpen(booleanExtra4).setPerfUploadFrequency(longExtra2).setAESKey(bt.a(getApplicationContext())).setEventEncrypted(booleanExtra5).setMaxFileLength(longExtra3).build(getApplicationContext());
                if (!"com.xiaomi.xmsf".equals(getPackageName()) && longExtra > 0 && longExtra2 > 0 && longExtra3 > 0) {
                    eo.a(getApplicationContext(), build);
                }
            } else if ("action_help_ping".equals(intent.getAction())) {
                boolean booleanExtra6 = intent.getBooleanExtra("extra_help_ping_switch", false);
                int intExtra4 = intent.getIntExtra("extra_help_ping_frequency", 0);
                if (intExtra4 >= 0 && intExtra4 < 30) {
                    com.xiaomi.channel.commonutils.logger.b.c("aw_ping: frquency need > 30s.");
                    intExtra4 = 30;
                }
                if (intExtra4 >= 0) {
                    z2 = booleanExtra6;
                }
                com.xiaomi.channel.commonutils.logger.b.m9051a("aw_ping: receive a aw_ping message. switch: " + z2 + " frequency: " + intExtra4);
                if (z2 && intExtra4 > 0 && !"com.xiaomi.xmsf".equals(getPackageName())) {
                    a(intent, intExtra4);
                }
            } else if ("action_aw_app_logic".equals(intent.getAction())) {
                e(intent);
            }
        }
    }

    private void e() {
        if (!m9632a()) {
            ev.a();
        } else if (!ev.m9336a()) {
            ev.a(true);
        }
    }

    private void e(Intent intent) {
        int i2;
        try {
            ee.a(getApplicationContext()).a(new bj());
            String stringExtra = intent.getStringExtra("mipush_app_package");
            byte[] byteArrayExtra = intent.getByteArrayExtra("mipush_payload");
            if (byteArrayExtra != null) {
                ii iiVar = new ii();
                it.a(iiVar, byteArrayExtra);
                String b2 = iiVar.b();
                Map<String, String> a2 = iiVar.m9517a();
                if (a2 != null) {
                    String str = a2.get("extra_help_aw_info");
                    String str2 = a2.get("extra_aw_app_online_cmd");
                    if (!TextUtils.isEmpty(str2)) {
                        try {
                            i2 = Integer.parseInt(str2);
                        } catch (NumberFormatException unused) {
                            i2 = 0;
                        }
                        if (!TextUtils.isEmpty(stringExtra) && !TextUtils.isEmpty(b2) && !TextUtils.isEmpty(str)) {
                            ee.a(getApplicationContext()).a(this, str, i2, stringExtra, b2);
                        }
                    }
                }
            }
        } catch (iz e2) {
            com.xiaomi.channel.commonutils.logger.b.d("aw_logic: translate fail. " + e2.getMessage());
        }
    }

    /* renamed from: e  reason: collision with other method in class */
    public static boolean m9624e() {
        return b;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void f() {
        String str;
        fp fpVar = this.f7477a;
        if (fpVar == null || !fpVar.m9367b()) {
            fp fpVar2 = this.f7477a;
            if (fpVar2 == null || !fpVar2.m9368c()) {
                this.f7478a.b(bj.m9153a((Context) this));
                g();
                if (this.f7477a == null) {
                    bd.a().a(this);
                    c(false);
                    return;
                }
                return;
            }
            str = "try to connect while is connected.";
        } else {
            str = "try to connect while connecting.";
        }
        com.xiaomi.channel.commonutils.logger.b.d(str);
    }

    /* renamed from: f  reason: collision with other method in class */
    private boolean m9625f() {
        if (SystemClock.elapsedRealtime() - this.f7473a < 30000) {
            return false;
        }
        return bj.d(this);
    }

    private void g() {
        try {
            this.f7476a.a(this.f7479a, new cj(this));
            this.f7476a.e();
            this.f7477a = this.f7476a;
        } catch (ga e2) {
            com.xiaomi.channel.commonutils.logger.b.a("fail to create Slim connection", e2);
            this.f7476a.b(3, e2);
        }
    }

    /* renamed from: g  reason: collision with other method in class */
    private boolean m9626g() {
        return "com.xiaomi.xmsf".equals(getPackageName()) && Settings.Secure.getInt(getContentResolver(), "EXTREME_POWER_MODE_ENABLE", 0) == 1;
    }

    private void h() {
    }

    /* renamed from: h  reason: collision with other method in class */
    private boolean m9627h() {
        return "com.xiaomi.xmsf".equals(getPackageName()) && Settings.System.getInt(getContentResolver(), "power_supersave_mode_open", 0) == 1;
    }

    private void i() {
        synchronized (this.f7491a) {
            this.f7491a.clear();
        }
    }

    /* renamed from: i  reason: collision with other method in class */
    private boolean m9628i() {
        return "com.xiaomi.xmsf".equals(getPackageName()) || !t.a(this).m9743b(getPackageName());
    }

    private boolean j() {
        return getApplicationContext().getPackageName().equals("com.xiaomi.xmsf") && k() && !com.xiaomi.push.i.m9478b(this) && !com.xiaomi.push.i.m9475a(getApplicationContext());
    }

    private boolean k() {
        int intValue = Integer.valueOf(String.format("%tH", new Date())).intValue();
        int i2 = this.a;
        int i3 = this.f7494b;
        if (i2 <= i3) {
            return i2 < i3 && intValue >= i2 && intValue < i3;
        }
        if (intValue >= i2 || intValue < i3) {
            return true;
        }
    }

    private boolean l() {
        if (TextUtils.equals(getPackageName(), "com.xiaomi.xmsf")) {
            return false;
        }
        return ax.a(this).a(ho.ForegroundServiceSwitch.a(), false);
    }

    /* renamed from: a  reason: collision with other method in class */
    public fp m9629a() {
        return this.f7477a;
    }

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

    /* access modifiers changed from: package-private */
    /* renamed from: a  reason: collision with other method in class */
    public void m9631a() {
        if (SystemClock.elapsedRealtime() - this.f7473a >= ((long) fv.a()) && bj.d(this)) {
            b(true);
        }
    }

    public void a(int i2) {
        this.f7488a.a(i2);
    }

    public void a(int i2, Exception exc) {
        StringBuilder sb = new StringBuilder("disconnect ");
        sb.append(hashCode());
        sb.append(", ");
        fp fpVar = this.f7477a;
        sb.append(fpVar == null ? null : Integer.valueOf(fpVar.hashCode()));
        com.xiaomi.channel.commonutils.logger.b.m9051a(sb.toString());
        fp fpVar2 = this.f7477a;
        if (fpVar2 != null) {
            fpVar2.b(i2, exc);
            this.f7477a = null;
        }
        a(7);
        a(4);
        bd.a().a(this, i2);
    }

    public void a(fe feVar) {
        fp fpVar = this.f7477a;
        if (fpVar != null) {
            fpVar.b(feVar);
            return;
        }
        throw new ga("try send msg while connection is null.");
    }

    @Override // com.xiaomi.push.fs
    public void a(fp fpVar) {
        com.xiaomi.channel.commonutils.logger.b.c("begin to connect...");
        hb.a().a(fpVar);
    }

    @Override // com.xiaomi.push.fs
    public void a(fp fpVar, int i2, Exception exc) {
        hb.a().a(fpVar, i2, exc);
        if (!j()) {
            a(false);
        }
    }

    @Override // com.xiaomi.push.fs
    public void a(fp fpVar, Exception exc) {
        hb.a().a(fpVar, exc);
        c(false);
        if (!j()) {
            a(false);
        }
    }

    public void a(j jVar) {
        a(jVar, 0);
    }

    public void a(j jVar, long j2) {
        try {
            this.f7488a.a(jVar, j2);
        } catch (IllegalStateException e2) {
            com.xiaomi.channel.commonutils.logger.b.m9051a("can't execute job err = " + e2.getMessage());
        }
    }

    public void a(n nVar) {
        synchronized (this.f7491a) {
            this.f7491a.add(nVar);
        }
    }

    public void a(bd.b bVar) {
        if (bVar != null) {
            long a2 = bVar.a();
            com.xiaomi.channel.commonutils.logger.b.m9051a("schedule rebind job in " + (a2 / 1000));
            a(new b(bVar), a2);
        }
    }

    public void a(String str, String str2, int i2, String str3, String str4) {
        bd.b a2 = bd.a().a(str, str2);
        if (a2 != null) {
            a(new s(a2, i2, str4, str3));
        }
        bd.a().m9696a(str, str2);
    }

    /* access modifiers changed from: package-private */
    public void a(String str, byte[] bArr, boolean z) {
        Collection<bd.b> a2 = bd.a().m9692a("5");
        if (a2.isEmpty()) {
            if (z) {
                v.b(str, bArr);
            }
        } else if (a2.iterator().next().f7559a == bd.c.binded) {
            a(new ch(this, 4, str, bArr));
        } else if (z) {
            v.b(str, bArr);
        }
    }

    public void a(boolean z) {
        this.f7486a.a(z);
    }

    public void a(byte[] bArr, String str) {
        if (bArr == null) {
            v.a(this, str, bArr, ErrorCode.ERROR_INVALID_PAYLOAD, "null payload");
            com.xiaomi.channel.commonutils.logger.b.m9051a("register request without payload");
            return;
        }
        Cif ifVar = new Cif();
        try {
            it.a(ifVar, bArr);
            if (ifVar.f7263a == hj.Registration) {
                ij ijVar = new ij();
                try {
                    it.a(ijVar, ifVar.m9507a());
                    a(new u(this, ifVar.b(), ijVar.b(), ijVar.c(), bArr));
                    ep.a(getApplicationContext()).a(ifVar.b(), "E100003", ijVar.a(), AuthCode.StatusCode.AUTH_INFO_NOT_EXIST, null);
                } catch (iz e2) {
                    com.xiaomi.channel.commonutils.logger.b.d("app register error. " + e2);
                    v.a(this, str, bArr, ErrorCode.ERROR_INVALID_PAYLOAD, " data action error.");
                }
            } else {
                v.a(this, str, bArr, ErrorCode.ERROR_INVALID_PAYLOAD, " registration action required.");
                com.xiaomi.channel.commonutils.logger.b.m9051a("register request with invalid payload");
            }
        } catch (iz e3) {
            com.xiaomi.channel.commonutils.logger.b.d("app register fail. " + e3);
            v.a(this, str, bArr, ErrorCode.ERROR_INVALID_PAYLOAD, " data container error.");
        }
    }

    public void a(fe[] feVarArr) {
        fp fpVar = this.f7477a;
        if (fpVar != null) {
            fpVar.a(feVarArr);
            return;
        }
        throw new ga("try send msg while connection is null.");
    }

    /* renamed from: a  reason: collision with other method in class */
    public boolean m9632a() {
        boolean b2 = bj.b(this);
        boolean z = bd.a().m9690a() > 0;
        boolean z2 = !m9636b();
        boolean i2 = m9628i();
        boolean z3 = !m9627h();
        boolean z4 = !m9626g();
        boolean z5 = b2 && z && z2 && i2 && z3 && z4;
        if (!z5) {
            com.xiaomi.channel.commonutils.logger.b.e(String.format("not conn, net=%s;cnt=%s;!dis=%s;enb=%s;!spm=%s;!eps=%s", Boolean.valueOf(b2), Boolean.valueOf(z), Boolean.valueOf(z2), Boolean.valueOf(i2), Boolean.valueOf(z3), Boolean.valueOf(z4)));
        }
        return z5;
    }

    /* renamed from: a  reason: collision with other method in class */
    public boolean m9633a(int i2) {
        return this.f7488a.m9730a(i2);
    }

    /* renamed from: b  reason: collision with other method in class */
    public j m9634b() {
        return this.f7487a;
    }

    /* access modifiers changed from: package-private */
    /* renamed from: b  reason: collision with other method in class */
    public void m9635b() {
        m.a(getApplicationContext()).m9727d();
        Iterator it = new ArrayList(this.f7491a).iterator();
        while (it.hasNext()) {
            ((n) it.next()).a();
        }
    }

    @Override // com.xiaomi.push.fs
    public void b(fp fpVar) {
        hb.a().b(fpVar);
        c(true);
        this.f7486a.m9704a();
        if (!ev.m9336a() && !j()) {
            com.xiaomi.channel.commonutils.logger.b.m9051a("reconnection successful, reactivate alarm.");
            ev.a(true);
        }
        Iterator<bd.b> it = bd.a().m9691a().iterator();
        while (it.hasNext()) {
            a(new b(it.next()));
        }
        if (!this.f7493a && com.xiaomi.push.l.m9609a(getApplicationContext())) {
            al.a(getApplicationContext()).a(new ck(this));
        }
    }

    public void b(j jVar) {
        this.f7488a.a(jVar.a, jVar);
    }

    /* renamed from: b  reason: collision with other method in class */
    public boolean m9636b() {
        try {
            Class<?> a2 = v.a(this, "miui.os.Build");
            return a2.getField("IS_CM_CUSTOMIZATION_TEST").getBoolean(null) || a2.getField("IS_CU_CUSTOMIZATION_TEST").getBoolean(null) || a2.getField("IS_CT_CUSTOMIZATION_TEST").getBoolean(null);
        } catch (Throwable unused) {
            return false;
        }
    }

    /* renamed from: c  reason: collision with other method in class */
    public boolean m9637c() {
        fp fpVar = this.f7477a;
        return fpVar != null && fpVar.m9368c();
    }

    /* renamed from: d  reason: collision with other method in class */
    public boolean m9638d() {
        fp fpVar = this.f7477a;
        return fpVar != null && fpVar.m9367b();
    }

    public IBinder onBind(Intent intent) {
        return this.f7475a.getBinder();
    }

    public void onCreate() {
        String[] split;
        super.onCreate();
        com.xiaomi.channel.commonutils.logger.b.a(getApplicationContext());
        v.m9751a((Context) this);
        r a2 = s.m9739a((Context) this);
        if (a2 != null) {
            ae.a(a2.a);
        }
        if (com.xiaomi.push.l.m9609a(getApplicationContext())) {
            HandlerThread handlerThread = new HandlerThread("hb-alarm");
            handlerThread.start();
            Handler handler = new Handler(handlerThread.getLooper());
            this.f7480a = new a(this, null);
            registerReceiver(this.f7480a, new IntentFilter(bh.o), null, handler);
            b = true;
            handler.post(new cl(this));
        }
        this.f7475a = new Messenger(new cm(this));
        bi.a(this);
        cn cnVar = new cn(this, null, 5222, "xiaomi.com", null);
        this.f7478a = cnVar;
        cnVar.a(true);
        this.f7476a = new fl(this, this.f7478a);
        this.f7487a = m9630a();
        ev.a(this);
        this.f7476a.a(this);
        this.f7485a = new bb(this);
        this.f7486a = new bn(this);
        new k().a();
        hb.m9413a().a(this);
        this.f7488a = new n("Connection Controller Thread");
        bd a3 = bd.a();
        a3.b();
        a3.a(new co(this));
        if (l()) {
            h();
        }
        hh.a(this).a(new p(this), "UPLOADER_PUSH_CHANNEL");
        a(new he(this));
        a(new cd(this));
        if (com.xiaomi.push.l.m9609a((Context) this)) {
            a(new bc());
        }
        a(new h());
        this.f7492a.add(bu.a(this));
        if (m9628i()) {
            this.f7481a = new f();
            registerReceiver(this.f7481a, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
        }
        if (com.xiaomi.push.l.m9609a(getApplicationContext())) {
            this.f7484a = new t();
            registerReceiver(this.f7484a, new IntentFilter("miui.net.wifi.DIGEST_INFORMATION_CHANGED"), "miui.net.wifi.permission.ACCESS_WIFI_DIGEST_INFO", null);
            k kVar = new k();
            this.f7482a = kVar;
            registerReceiver(kVar, new IntentFilter("com.xiaomi.xmsf.USE_INTELLIGENT_HB"), "com.xiaomi.xmsf.permission.INTELLIGENT_HB", null);
        }
        m.a(getApplicationContext()).m9723a();
        if ("com.xiaomi.xmsf".equals(getPackageName())) {
            Uri uriFor = Settings.Secure.getUriFor("EXTREME_POWER_MODE_ENABLE");
            if (uriFor != null) {
                this.f7474a = new cp(this, new Handler(Looper.getMainLooper()));
                try {
                    getContentResolver().registerContentObserver(uriFor, false, this.f7474a);
                } catch (Throwable th) {
                    com.xiaomi.channel.commonutils.logger.b.m9051a("register observer err:" + th.getMessage());
                }
            }
            Uri uriFor2 = Settings.System.getUriFor("power_supersave_mode_open");
            if (uriFor2 != null) {
                this.f7495b = new cq(this, new Handler(Looper.getMainLooper()));
                try {
                    getContentResolver().registerContentObserver(uriFor2, false, this.f7495b);
                } catch (Throwable th2) {
                    com.xiaomi.channel.commonutils.logger.b.d("register super-power-mode observer err:" + th2.getMessage());
                }
            }
            int[] a4 = m9623a();
            if (a4 != null) {
                this.f7483a = new r();
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction("android.intent.action.SCREEN_ON");
                intentFilter.addAction("android.intent.action.SCREEN_OFF");
                registerReceiver(this.f7483a, intentFilter);
                this.a = a4[0];
                this.f7494b = a4[1];
                com.xiaomi.channel.commonutils.logger.b.m9051a("falldown initialized: " + this.a + Constants.ACCEPT_TIME_SEPARATOR_SP + this.f7494b);
            }
        }
        String str = "";
        if (a2 != null) {
            try {
                if (!TextUtils.isEmpty(a2.f7630a) && (split = a2.f7630a.split("@")) != null && split.length > 0) {
                    str = split[0];
                }
            } catch (Exception unused) {
            }
        }
        dd.a(this);
        com.xiaomi.channel.commonutils.logger.b.e("XMPushService created. pid=" + Process.myPid() + ", uid=" + Process.myUid() + ", vc=" + com.xiaomi.push.g.a(getApplicationContext(), getPackageName()) + ", uuid=" + str);
    }

    public void onDestroy() {
        f fVar = this.f7481a;
        if (fVar != null) {
            a(fVar);
            this.f7481a = null;
        }
        t tVar = this.f7484a;
        if (tVar != null) {
            a(tVar);
            this.f7484a = null;
        }
        k kVar = this.f7482a;
        if (kVar != null) {
            a(kVar);
            this.f7482a = null;
        }
        r rVar = this.f7483a;
        if (rVar != null) {
            a(rVar);
            this.f7483a = null;
        }
        a aVar = this.f7480a;
        if (aVar != null) {
            a(aVar);
            this.f7480a = null;
        }
        if ("com.xiaomi.xmsf".equals(getPackageName()) && this.f7474a != null) {
            try {
                getContentResolver().unregisterContentObserver(this.f7474a);
            } catch (Throwable th) {
                com.xiaomi.channel.commonutils.logger.b.m9051a("unregister observer err:" + th.getMessage());
            }
        }
        if ("com.xiaomi.xmsf".equals(getPackageName()) && this.f7495b != null) {
            try {
                getContentResolver().unregisterContentObserver(this.f7495b);
            } catch (Throwable th2) {
                com.xiaomi.channel.commonutils.logger.b.d("unregister super-power-mode err:" + th2.getMessage());
            }
        }
        this.f7492a.clear();
        this.f7488a.m9731b();
        a(new ci(this, 2));
        a(new l());
        bd.a().b();
        bd.a().a(this, 15);
        bd.a().m9694a();
        this.f7476a.b(this);
        bs.a().m9709a();
        ev.a();
        i();
        super.onDestroy();
        com.xiaomi.channel.commonutils.logger.b.m9051a("Service destroyed");
    }

    public void onStart(Intent intent, int i2) {
        i iVar;
        long currentTimeMillis = System.currentTimeMillis();
        if (intent == null) {
            com.xiaomi.channel.commonutils.logger.b.d("onStart() with intent NULL");
        } else {
            com.xiaomi.channel.commonutils.logger.b.m9051a(String.format("onStart() with intent.Action = %s, chid = %s, pkg = %s|%s", intent.getAction(), intent.getStringExtra(bh.s), intent.getStringExtra(bh.A), intent.getStringExtra("mipush_app_package")));
        }
        if (!(intent == null || intent.getAction() == null)) {
            if ("com.xiaomi.push.timer".equalsIgnoreCase(intent.getAction()) || "com.xiaomi.push.check_alive".equalsIgnoreCase(intent.getAction())) {
                if (this.f7488a.m9729a()) {
                    com.xiaomi.channel.commonutils.logger.b.d("ERROR, the job controller is blocked.");
                    bd.a().a(this, 14);
                    stopSelf();
                } else {
                    iVar = new i(intent);
                }
            } else if (!"com.xiaomi.push.network_status_changed".equalsIgnoreCase(intent.getAction())) {
                iVar = new i(intent);
            }
            a(iVar);
        }
        long currentTimeMillis2 = System.currentTimeMillis() - currentTimeMillis;
        if (currentTimeMillis2 > 50) {
            com.xiaomi.channel.commonutils.logger.b.c("[Prefs] spend " + currentTimeMillis2 + " ms, too more times.");
        }
    }

    public int onStartCommand(Intent intent, int i2, int i3) {
        onStart(intent, i3);
        return 1;
    }
}