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


package com.xiaomi.push.service;

import android.content.Context;
import android.content.Intent;
import android.os.Message;
import android.os.RemoteException;
import android.os.SystemClock;
import android.text.TextUtils;
import com.xiaomi.channel.commonutils.logger.b;
import com.xiaomi.push.fe;
import com.xiaomi.push.ge;
import com.xiaomi.push.gf;
import com.xiaomi.push.gg;
import com.xiaomi.push.gi;
import com.xiaomi.push.l;
import com.xiaomi.push.service.bd;
import java.util.Collection;
import java.util.Iterator;

public class j {
    private w a = new w();

    public static String a(bd.b bVar) {
        StringBuilder sb;
        String str;
        if (!"9".equals(bVar.g)) {
            sb = new StringBuilder();
            sb.append(bVar.f7561a);
            str = ".permission.MIPUSH_RECEIVE";
        } else {
            sb = new StringBuilder();
            sb.append(bVar.f7561a);
            str = ".permission.MIMC_RECEIVE";
        }
        sb.append(str);
        return sb.toString();
    }

    private static void a(Context context, Intent intent, bd.b bVar) {
        if ("com.xiaomi.xmsf".equals(context.getPackageName())) {
            context.sendBroadcast(intent);
        } else {
            context.sendBroadcast(intent, a(bVar));
        }
    }

    /* access modifiers changed from: package-private */
    public bd.b a(fe feVar) {
        Collection<bd.b> a2 = bd.a().m9692a(Integer.toString(feVar.a()));
        if (a2.isEmpty()) {
            return null;
        }
        Iterator<bd.b> it = a2.iterator();
        if (a2.size() == 1) {
            return it.next();
        }
        String g = feVar.g();
        while (it.hasNext()) {
            bd.b next = it.next();
            if (TextUtils.equals(g, next.f7564b)) {
                return next;
            }
        }
        return null;
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Removed duplicated region for block: B:10:0x0034  */
    public bd.b a(gg ggVar) {
        Collection<bd.b> a2 = bd.a().m9692a(ggVar.k());
        if (a2.isEmpty()) {
            return null;
        }
        Iterator<bd.b> it = a2.iterator();
        if (a2.size() == 1) {
            return it.next();
        }
        String m = ggVar.m();
        String l = ggVar.l();
        while (it.hasNext()) {
            bd.b next = it.next();
            if (TextUtils.equals(m, next.f7564b) || TextUtils.equals(l, next.f7564b)) {
                return next;
            }
            while (it.hasNext()) {
            }
        }
        return null;
    }

    public void a(Context context) {
        Intent intent = new Intent();
        intent.setAction("com.xiaomi.push.service_started");
        if (l.m9613c()) {
            intent.addFlags(16777216);
        }
        b.m9051a("[Bcst] send ***.push.service_started broadcast to inform push service has started.");
        context.sendBroadcast(intent);
    }

    public void a(Context context, bd.b bVar, int i) {
        if (!"5".equalsIgnoreCase(bVar.g)) {
            Intent intent = new Intent();
            intent.setAction("com.xiaomi.push.channel_closed");
            intent.setPackage(bVar.f7561a);
            intent.putExtra(bh.s, bVar.g);
            intent.putExtra("ext_reason", i);
            intent.putExtra(bh.p, bVar.f7564b);
            intent.putExtra(bh.E, bVar.i);
            if (bVar.f7555a == null || !"9".equals(bVar.g)) {
                b.m9051a(String.format("[Bcst] notify channel closed. %s,%s,%d", bVar.g, bVar.f7561a, Integer.valueOf(i)));
                a(context, intent, bVar);
                return;
            }
            try {
                bVar.f7555a.send(Message.obtain(null, 17, intent));
            } catch (RemoteException unused) {
                bVar.f7555a = null;
                b.m9051a("peer may died: " + bVar.f7564b.substring(bVar.f7564b.lastIndexOf(64)));
            }
        }
    }

    public void a(Context context, bd.b bVar, String str, String str2) {
        if (bVar == null) {
            b.d("error while notify kick by server!");
        } else if ("5".equalsIgnoreCase(bVar.g)) {
            b.d("mipush kicked by server");
        } else {
            Intent intent = new Intent();
            intent.setAction("com.xiaomi.push.kicked");
            intent.setPackage(bVar.f7561a);
            intent.putExtra("ext_kick_type", str);
            intent.putExtra("ext_kick_reason", str2);
            intent.putExtra("ext_chid", bVar.g);
            intent.putExtra(bh.p, bVar.f7564b);
            intent.putExtra(bh.E, bVar.i);
            b.m9051a(String.format("[Bcst] notify packet(blob) arrival. %s,%s,%s", bVar.g, bVar.f7561a, str2));
            a(context, intent, bVar);
        }
    }

    public void a(Context context, bd.b bVar, boolean z, int i, String str) {
        if ("5".equalsIgnoreCase(bVar.g)) {
            this.a.a(context, bVar, z, i, str);
            return;
        }
        Intent intent = new Intent();
        intent.setAction("com.xiaomi.push.channel_opened");
        intent.setPackage(bVar.f7561a);
        intent.putExtra("ext_succeeded", z);
        if (!z) {
            intent.putExtra("ext_reason", i);
        }
        if (!TextUtils.isEmpty(str)) {
            intent.putExtra("ext_reason_msg", str);
        }
        intent.putExtra("ext_chid", bVar.g);
        intent.putExtra(bh.p, bVar.f7564b);
        intent.putExtra(bh.E, bVar.i);
        b.m9051a(String.format("[Bcst] notify channel open result. %s,%s,%b,%d", bVar.g, bVar.f7561a, Boolean.valueOf(z), Integer.valueOf(i)));
        a(context, intent, bVar);
    }

    public void a(XMPushService xMPushService, String str, fe feVar) {
        bd.b a2 = a(feVar);
        if (a2 == null) {
            b.d("error while notify channel closed! channel " + str + " not registered");
        } else if ("5".equalsIgnoreCase(str)) {
            this.a.a(xMPushService, feVar, a2);
        } else {
            String str2 = a2.f7561a;
            Intent intent = new Intent();
            intent.setAction("com.xiaomi.push.new_msg");
            intent.setPackage(str2);
            intent.putExtra("ext_rcv_timestamp", SystemClock.elapsedRealtime());
            intent.putExtra("ext_chid", str);
            intent.putExtra("ext_raw_packet", feVar.m9349a(a2.h));
            intent.putExtra(bh.E, a2.i);
            intent.putExtra(bh.w, a2.h);
            if (a2.f7555a != null) {
                try {
                    a2.f7555a.send(Message.obtain(null, 17, intent));
                    b.m9051a("message was sent by messenger for chid=" + str);
                    return;
                } catch (RemoteException unused) {
                    a2.f7555a = null;
                    b.m9051a("peer may died: " + a2.f7564b.substring(a2.f7564b.lastIndexOf(64)));
                }
            }
            if (!"com.xiaomi.xmsf".equals(str2)) {
                b.m9051a(String.format("[Bcst] notify packet(blob) arrival. %s,%s,%s", a2.g, a2.f7561a, feVar.e()));
                a(xMPushService, intent, a2);
            }
        }
    }

    public void a(XMPushService xMPushService, String str, gg ggVar) {
        String str2;
        bd.b a2 = a(ggVar);
        if (a2 == null) {
            b.d("error while notify channel closed! channel " + str + " not registered");
        } else if ("5".equalsIgnoreCase(str)) {
            this.a.a(xMPushService, ggVar, a2);
        } else {
            String str3 = a2.f7561a;
            if (ggVar instanceof gf) {
                str2 = "com.xiaomi.push.new_msg";
            } else if (ggVar instanceof ge) {
                str2 = "com.xiaomi.push.new_iq";
            } else if (ggVar instanceof gi) {
                str2 = "com.xiaomi.push.new_pres";
            } else {
                b.d("unknown packet type, drop it");
                return;
            }
            Intent intent = new Intent();
            intent.setAction(str2);
            intent.setPackage(str3);
            intent.putExtra("ext_chid", str);
            intent.putExtra("ext_packet", ggVar.a());
            intent.putExtra(bh.E, a2.i);
            intent.putExtra(bh.w, a2.h);
            b.m9051a(String.format("[Bcst] notify packet arrival. %s,%s,%s", a2.g, a2.f7561a, ggVar.j()));
            a(xMPushService, intent, a2);
        }
    }
}