package cn.jpush.android.service;

import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Process;
import cn.jpush.android.a;
import cn.jpush.android.api.BasicPushNotificationBuilder;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;
import cn.jpush.android.api.b;
import cn.jpush.android.api.d;
import cn.jpush.android.api.m;
import cn.jpush.android.data.c;
import cn.jpush.android.e;
import cn.jpush.android.util.z;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;

public class ServiceInterface {
    private static boolean a = false;
    private static final String[] z;

    public class TagAliasOperator extends BroadcastReceiver {
        private static TagAliasOperator a;
        private static Object c = new Object();
        private static final String[] z;
        private ConcurrentHashMap<Long, b> b = new ConcurrentHashMap();
        private AtomicBoolean d = new AtomicBoolean(false);

        /* JADX WARNING: inconsistent code. */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        static {
            /*
            r0 = 15;
            r3 = new java.lang.String[r0];
            r2 = 0;
            r1 = "74~nlx%nh{(4dp";
            r0 = -1;
            r4 = r3;
        L_0x0009:
            r1 = r1.toCharArray();
            r5 = r1.length;
            r6 = 0;
            r7 = 1;
            if (r5 > r7) goto L_0x002e;
        L_0x0012:
            r7 = r1;
            r8 = r6;
            r11 = r5;
            r5 = r1;
            r1 = r11;
        L_0x0017:
            r10 = r5[r6];
            r9 = r8 % 5;
            switch(r9) {
                case 0: goto L_0x00cc;
                case 1: goto L_0x00d0;
                case 2: goto L_0x00d4;
                case 3: goto L_0x00d8;
                default: goto L_0x001e;
            };
        L_0x001e:
            r9 = 30;
        L_0x0020:
            r9 = r9 ^ r10;
            r9 = (char) r9;
            r5[r6] = r9;
            r6 = r8 + 1;
            if (r1 != 0) goto L_0x002c;
        L_0x0028:
            r5 = r7;
            r8 = r6;
            r6 = r1;
            goto L_0x0017;
        L_0x002c:
            r5 = r1;
            r1 = r7;
        L_0x002e:
            if (r5 > r6) goto L_0x0012;
        L_0x0030:
            r5 = new java.lang.String;
            r5.<init>(r1);
            r1 = r5.intern();
            switch(r0) {
                case 0: goto L_0x0044;
                case 1: goto L_0x004c;
                case 2: goto L_0x0054;
                case 3: goto L_0x005c;
                case 4: goto L_0x0064;
                case 5: goto L_0x006c;
                case 6: goto L_0x0074;
                case 7: goto L_0x007d;
                case 8: goto L_0x0088;
                case 9: goto L_0x0094;
                case 10: goto L_0x009f;
                case 11: goto L_0x00aa;
                case 12: goto L_0x00b5;
                case 13: goto L_0x00c0;
                default: goto L_0x003c;
            };
        L_0x003c:
            r3[r2] = r1;
            r2 = 1;
            r1 = "\n%unw.%d+p746y{?)e{*%r'>;!xeq,`ujr4`cel='xj=2Dn}=)`nl";
            r0 = 0;
            r3 = r4;
            goto L_0x0009;
        L_0x0044:
            r3[r2] = r1;
            r2 = 2;
            r1 = "\u000b%d}w;%_ej=2pj}=";
            r0 = 1;
            r3 = r4;
            goto L_0x0009;
        L_0x004c:
            r3[r2] = r1;
            r2 = 3;
            r1 = ";.8an-3~%6$ddw<nej=.b%J\u0019\u0007IJR\u0011\u0001ET]\u0019\fZI_\u001b\u000b";
            r0 = 2;
            r3 = r4;
            goto L_0x0009;
        L_0x0054:
            r3[r2] = r1;
            r2 = 4;
            r1 = ";.8an-3~%6$ddw<nej=.b%J\u0019\u0007IJR\u0011\u0001ETJ\u0011\rSDK\f";
            r0 = 3;
            r3 = r4;
            goto L_0x0009;
        L_0x005c:
            r3[r2] = r1;
            r2 = 5;
            r1 = "+%b_?\u0001xo_4)wx>=z";
            r0 = 4;
            r3 = r4;
            goto L_0x0009;
        L_0x0064:
            r3[r2] = r1;
            r2 = 6;
            r1 = ",!qjr1!eTm=1o";
            r0 = 5;
            r3 = r4;
            goto L_0x0009;
        L_0x006c:
            r3[r2] = r1;
            r2 = 7;
            r1 = "\u000b%bJr1!eJp<\u0014wlmx4f{75b+l1$,";
            r0 = 6;
            r3 = r4;
            goto L_0x0009;
        L_0x0074:
            r3[r2] = r1;
            r2 = 8;
            r1 = "R#wgr\u001a!u`09,jmb";
            r0 = 7;
            r3 = r4;
            goto L_0x0009;
        L_0x007d:
            r3[r2] = r1;
            r2 = 9;
            r1 = "x2o$";
            r0 = 8;
            r3 = r4;
            goto L_0x0009;
        L_0x0088:
            r3[r2] = r1;
            r2 = 10;
            r1 = "x4wl_4)wx]9,zi;+e+$";
            r0 = 9;
            r3 = r4;
            goto L_0x0009;
        L_0x0094:
            r3[r2] = r1;
            r2 = 11;
            r1 = "+\u0014wlmb";
            r0 = 10;
            r3 = r4;
            goto L_0x0009;
        L_0x009f:
            r3[r2] = r1;
            r2 = 12;
            r1 = "\u000b%bJr1!eJp<\u0014wlmx&ew+(61>=2ddl\u001b/rn$";
            r0 = 11;
            r3 = r4;
            goto L_0x0009;
        L_0x00aa:
            r3[r2] = r1;
            r2 = 13;
            r1 = ",!qjr1!eT{*2yy}7$s";
            r0 = 12;
            r3 = r4;
            goto L_0x0009;
        L_0x00b5:
            r3[r2] = r1;
            r2 = 14;
            r1 = ",!qjr1!e+}9,zi;+6bmx.cgrc`dbze";
            r0 = 13;
            r3 = r4;
            goto L_0x0009;
        L_0x00c0:
            r3[r2] = r1;
            z = r4;
            r0 = new java.lang.Object;
            r0.<init>();
            c = r0;
            return;
        L_0x00cc:
            r9 = 88;
            goto L_0x0020;
        L_0x00d0:
            r9 = 64;
            goto L_0x0020;
        L_0x00d4:
            r9 = 22;
            goto L_0x0020;
        L_0x00d8:
            r9 = 11;
            goto L_0x0020;
            */
            throw new UnsupportedOperationException("Method not decompiled: cn.jpush.android.service.ServiceInterface.TagAliasOperator.<clinit>():void");
        }

        private TagAliasOperator() {
        }

        private b a(long j) {
            return (b) this.b.get(Long.valueOf(j));
        }

        public static TagAliasOperator a() {
            synchronized (c) {
                if (a == null) {
                    a = new TagAliasOperator();
                }
            }
            return a;
        }

        private void b(long j) {
            this.b.remove(Long.valueOf(j));
        }

        private synchronized void b(Context context) {
            if (this.d.get() && this.b != null && this.b.isEmpty()) {
                try {
                    context.unregisterReceiver(this);
                } catch (Throwable e) {
                    z.a(z[2], z[1], e);
                } catch (Throwable e2) {
                    z.a(z[2], z[0], e2);
                }
                this.d.set(false);
            }
            z.a();
        }

        public final void a(Context context) {
            if (this.d.get()) {
                z.b();
                return;
            }
            try {
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addCategory(e.c);
                intentFilter.addAction(z[4]);
                intentFilter.addAction(z[3]);
                context.registerReceiver(this, intentFilter);
                this.d.set(true);
            } catch (Exception e) {
                new StringBuilder(z[5]).append(e.getMessage());
                z.e();
            }
        }

        public final void a(Long l, b bVar) {
            this.b.put(l, bVar);
        }

        public void onReceive(Context context, Intent intent) {
            if (intent == null) {
                z.e();
                return;
            }
            long longExtra = intent.getLongExtra(z[6], -1);
            int intExtra = intent.getIntExtra(z[13], 0);
            if (longExtra == -1) {
                z.e();
                return;
            }
            new StringBuilder(z[9]).append(longExtra).append(z[10]).append(this.b.toString());
            z.e();
            if (z[4].equals(intent.getAction())) {
                new StringBuilder(z[7]).append(longExtra);
                z.a();
                b a = a(longExtra);
                if (a != null) {
                    TagAliasCallback tagAliasCallback = a.c;
                    b(longExtra);
                    if (tagAliasCallback != null) {
                        tagAliasCallback.gotResult(d.b, a.a, a.b);
                    }
                } else {
                    new StringBuilder(z[14]).append(longExtra);
                    z.d();
                }
            } else {
                new StringBuilder(z[12]).append(intExtra).append(z[9]).append(longExtra);
                z.a();
                b a2 = a(longExtra);
                if (a2 != null) {
                    TagAliasCallback tagAliasCallback2 = a2.c;
                    b(longExtra);
                    if (intExtra == 0) {
                        longExtra = System.currentTimeMillis();
                        String stringTags = JPushInterface.getStringTags(a2.b);
                        new StringBuilder(z[11]).append(stringTags).append(z[8]).append(a2.a);
                        z.a();
                        if (stringTags != null) {
                            a.j(stringTags);
                            a.d(longExtra);
                        }
                        if (a2.a != null) {
                            a.i(a2.a);
                            a.c(longExtra);
                        }
                    }
                    if (tagAliasCallback2 != null) {
                        tagAliasCallback2.gotResult(intExtra, a2.a, a2.b);
                    }
                } else {
                    new StringBuilder(z[14]).append(longExtra);
                    z.d();