智能工厂.apk(点击下载) / c.java


package cn.jpush.android.f;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ComponentInfo;
import android.os.Build;
import android.text.TextUtils;
import cn.jiguang.push.asus.PushMessageReceiver;
import cn.jpush.android.g.a;
import cn.jpush.android.g.d;
import cn.jpush.android.i.b;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
import org.json.JSONObject;

public final class c {
    public static Context a;
    public static String b;
    public static String c = null;
    public static boolean d = false;
    public static String e = "com.asus.as";
    private static AtomicLong f = new AtomicLong(0);
    private static a g;
    private static String h;
    private static Boolean i;
    private static ExecutorService j = Executors.newSingleThreadExecutor();

    public static long a() {
        long incrementAndGet = f.incrementAndGet();
        if (incrementAndGet == Long.MAX_VALUE) {
            f.set(0);
        }
        return incrementAndGet;
    }

    public static void a(Context context, String str, long j2, JSONObject jSONObject) {
        if (c(context)) {
            j.execute(new d(str, j2, jSONObject));
        }
    }

    static /* synthetic */ void a(String str, long j2, JSONObject jSONObject) {
        a aVar = g;
        if (!(aVar != null ? aVar.b() : false)) {
            b.a("Gobal", "connect has disconnect, will reconnect.");
            a aVar2 = g;
            if (aVar2 != null) {
                aVar2.a();
            }
        }
        if (jSONObject == null) {
            jSONObject = new JSONObject();
        }
        try {
            jSONObject.put("JPUSH_PACKAGE", c);
            if (j2 <= 0) {
                j2 = a();
            }
            jSONObject.put("JPUSH_RID", j2);
            String jSONObject2 = jSONObject.toString();
            b.c("Gobal", "cmd:" + str + ",data:" + jSONObject2);
            if (g != null) {
                g.a(str, jSONObject2);
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static boolean a(Context context) {
        return cn.jpush.android.g.c.a(context, e);
    }

    public static String b(Context context) {
        if (!TextUtils.isEmpty(h)) {
            return h;
        }
        try {
            Intent intent = new Intent();
            intent.setAction("com.ups.push.PUSH_RESPONSE");
            intent.setPackage(context.getPackageName());
            ComponentInfo a2 = cn.jpush.android.j.a.a(context, context.getPackageName(), PushMessageReceiver.class);
            if (a2 != null) {
                h = a2.name;
                cn.jpush.android.i.a.a("ASUS_PUSH", "Gobal", 4, "found userServiceClass :" + h + " by getComponentInfo");
            }
        } catch (Throwable th) {
            b.e("Gobal", "not found PushMessageReceiver :" + th.getMessage());
        }
        return h;
    }

    /* JADX WARNING: Removed duplicated region for block: B:18:0x0039  */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x004b  */
    private static boolean c(Context context) {
        Boolean bool;
        String str;
        String str2;
        Boolean bool2 = i;
        if (bool2 != null) {
            return bool2.booleanValue();
        }
        if (context == null) {
            b.g("Gobal", "context is null");
            return false;
        }
        d dVar = null;
        if (!cn.jpush.android.j.a.a(context)) {
            str = "ConnectionFactory";
            str2 = "Manufacturer not match, give up create connection.";
        } else if (!cn.jpush.android.g.c.a(context, e)) {
            str = "ConnectionFactory";
            str2 = "cn.jpush.android.service.PushManagerService not exist in system, give up create connection.";
        } else {
            dVar = new d();
            g = dVar;
            if (dVar != null) {
                b.g("Gobal", "unsupport this device.");
                bool = false;
            } else {
                Context applicationContext = context.getApplicationContext();
                a = applicationContext;
                c = applicationContext.getPackageName();
                cn.jpush.android.a.b.a(context);
                try {
                    NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
                    if (Build.VERSION.SDK_INT >= 26 && notificationManager.getNotificationChannel("asus_default_channel_id") == null) {
                        b.b("Gobal", "create default channel:默认");
                        notificationManager.createNotificationChannel(new NotificationChannel("asus_default_channel_id", "默认", 3));
                    }
                } catch (Throwable th) {
                    b.e("Gobal", "[initNotificationChannel] failed:" + th.getMessage());
                }
                bool = true;
            }
            i = bool;
            return bool.booleanValue();
        }
        b.f(str, str2);
        g = dVar;
        if (dVar != null) {
        }
        i = bool;
        return bool.booleanValue();
    }
}