package cn.jiguang.a; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.text.TextUtils; import cn.jiguang.android.IDataShare; import cn.jiguang.api.JCoreManager; import cn.jiguang.aq.c; import cn.jiguang.aw.e; import cn.jiguang.bd.b; import cn.jiguang.bd.d; import cn.jiguang.internal.JConstants; import cn.jiguang.internal.JCoreInternalHelper; import cn.jpush.android.service.DataShare; import cn.jpush.android.service.JCommonService; import cn.jpush.android.service.PushReceiver; import com.baidu.speech.utils.AsrError; public class a { public static String a = ".permission.JPUSH_MESSAGE"; public static String b = "2.3.8"; public static int c = 238; public static String d = ""; private static Boolean e; private static Boolean f; private static ServiceConnection g = new ServiceConnection() { /* class cn.jiguang.a.a.AnonymousClass1 */ public void onServiceConnected(ComponentName componentName, IBinder iBinder) { c.c("JCoreGobal", "action - onServiceConnected, ComponentName:" + componentName); c.e("JCoreGobal", "Remote Service bind success."); try { DataShare.init(IDataShare.Stub.asInterface(iBinder), cn.jiguang.ap.c.a(JConstants.getAppContext(null))); if (JConstants.mApplicationContext != null) { JCoreManager.init(JConstants.mApplicationContext); } } catch (Throwable th) { c.i("JCoreGobal", "onServiceConnected e:" + th); } } public void onServiceDisconnected(ComponentName componentName) { c.c("JCoreGobal", "action - onServiceDisconnected, ComponentName:" + componentName); } }; /* access modifiers changed from: package-private */ /* renamed from: cn.jiguang.a.a$a reason: collision with other inner class name */ public static class C0000a extends b { Context a; boolean b; String c; Bundle d; C0000a(Context context, boolean z, String str, Bundle bundle) { this.a = context; this.b = z; this.c = str; this.d = bundle; this.h = "JCoreGlobal"; } @Override // cn.jiguang.bd.b public void a() { String str; try { if (this.b) { if (this.c.equals("a5")) { cn.jiguang.aw.b.a().a(this.a, AsrError.ERROR_NETWORK_FAIL_READ, 1, ""); cn.jiguang.g.b.a(this.a, cn.jiguang.g.a.n().a((Boolean) true)); String string = this.d.getString("appkey"); if (TextUtils.isEmpty(string)) { cn.jiguang.aw.b.a().a(this.a, 0, AsrError.ERROR_OFFLINE_INVALID_LICENSE, "appkey is empty"); return; } String b2 = cn.jiguang.ap.a.b(this.a); if (TextUtils.isEmpty(b2) || b2.equals(string)) { cn.jiguang.f.a.h(this.a); JConstants.APP_KEY = string; if (cn.jiguang.aw.c.a(this.a)) { str = "tcp_a24"; } else { String b3 = cn.jiguang.d.a.b(this.a); if (!TextUtils.isEmpty(b3)) { cn.jiguang.aw.b.a().a(this.a, AsrError.ERROR_NETWORK_FAIL_READ, 0, b3); } str = "tcp_a1"; } this.c = str; } else { cn.jiguang.aw.b.a().a(this.a, 0, AsrError.ERROR_OFFLINE_NO_LICENSE, "appkey not same with meta appkey"); return; } } else if (this.c.equals("tcp_a23")) { cn.jiguang.aw.b.a().a(this.a, AsrError.ERROR_NETWORK_FAIL_CONNECT, 0, "success"); } if (a.b(this.a)) { cn.jiguang.ap.c.a().b(this.a, this.c, this.d); } } else if (a.a(this.a)) { cn.jiguang.ap.c.a().a(this.a, this.c, this.d); } } catch (Throwable th) { c.i("JCoreGobal", "do action error:" + th.getMessage()); } } } public static void a(Context context, String str, Bundle bundle) { if (TextUtils.isEmpty(cn.jiguang.ap.c.b(context)) || !context.getPackageName().equals(cn.jiguang.f.a.a(context))) { b(context, str, bundle); } else { d.a("SDK_INIT", new C0000a(context, false, str, bundle)); } } public static void a(Context context, boolean z, long j) { try { Bundle bundle = new Bundle(); bundle.putBoolean("force", z); bundle.putLong("delay_time", j); a(context, "tcp_a2", bundle); } catch (Throwable th) { c.h("JCoreGobal", "sendHeartBeat error:" + th); } } public static boolean a() { try { if (Class.forName("cn.jiguang.dy.b") != null) { } } catch (Throwable unused) { } return true; } public static synchronized boolean a(Context context) { synchronized (a.class) { if (e != null) { return e.booleanValue(); } else if (context == null) { c.j("JCoreGobal", "init failed,context is null"); return false; } else { c.f("JCoreGobal", "action:init jcore,version:" + b + ",build id:" + 15 + ",l:" + JConstants.SDK_VERSION_INT); c.c("JCoreGobal", "build type:release"); JConstants.mApplicationContext = context.getApplicationContext(); Context applicationContext = context.getApplicationContext(); cn.jiguang.ap.b.a(); String b2 = cn.jiguang.ap.c.b(applicationContext); if ((cn.jiguang.ap.b.a().c() || cn.jiguang.ap.b.a().b()) && TextUtils.isEmpty(b2)) { e = false; c.j("JCoreGobal", "AndroidManifest.xml missing required service:" + JCommonService.class.getCanonicalName() + ",please custom one service and extends JCommonService"); return false; } cn.jiguang.b.a.a().b(); d(applicationContext); e = true; return e.booleanValue(); } } } public static void b(Context context, String str, Bundle bundle) { d.a("SDK_SERVICE_INIT", new C0000a(context, true, str, bundle)); } public static synchronized boolean b(Context context) { synchronized (a.class) { if (f != null) { return f.booleanValue(); } else if (context == null) { c.j("JCoreGobal", "init failed,context is null"); return false; } else { c.c("JCoreGobal", "serviceInit..."); JConstants.mApplicationContext = context.getApplicationContext(); Context applicationContext = context.getApplicationContext(); if (!cn.jiguang.ap.a.e(applicationContext)) { return false; } if (!cn.jiguang.ap.a.f(applicationContext)) { f = false; return false; } if (a()) { try { JCoreInternalHelper.getInstance().onEvent(applicationContext, JConstants.SDK_TYPE, 65, true, "", null, 1); } catch (Throwable unused) { c.g("JCoreGobal", "u p call failed"); } } cn.jiguang.ap.b.a(); try { JConstants.isCallInit.set(true); } catch (Throwable unused2) { } c(applicationContext); f = true; cn.jiguang.b.a.a().e(applicationContext); e.a(applicationContext, "service_create", null); return f.booleanValue(); } } } private static void c(Context context) { try { IntentFilter intentFilter = new IntentFilter(); PushReceiver pushReceiver = new PushReceiver(); intentFilter.addAction("android.intent.action.USER_PRESENT"); intentFilter.addAction("android.intent.action.SCREEN_ON"); intentFilter.addAction("android.intent.action.SCREEN_OFF"); intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE"); String str = context.getPackageName() + a; context.registerReceiver(pushReceiver, intentFilter, str, null); if (!cn.jiguang.f.a.a(context, PushReceiver.class)) { IntentFilter intentFilter2 = new IntentFilter(); intentFilter2.addAction("android.intent.action.PACKAGE_ADDED"); intentFilter2.addAction("android.intent.action.PACKAGE_REMOVED"); intentFilter2.addDataScheme("package"); context.registerReceiver(pushReceiver, intentFilter2, str, null); } } catch (Throwable th) { c.i("JCoreGobal", "registerPushReceiver fail:" + th); } } private static void d(Context context) { String b2 = cn.jiguang.ap.c.b(context); if (TextUtils.isEmpty(b2)) { c.e("JCoreGobal", "not found commonServiceClass(JCommonService)"); } else if (DataShare.isBinding()) { c.c("JCoreGobal", "is binding service"); } else { try { Intent intent = new Intent(); intent.setClass(context, Class.forName(b2)); if (context.bindService(intent, g, 1)) { c.a("JCoreGobal", "Remote Service on binding..."); DataShare.setBinding(); return; } c.a("JCoreGobal", "Remote Service bind failed"); } catch (SecurityException unused) { c.h("JCoreGobal", "Remote Service bind failed caused by SecurityException!"); } catch (Throwable th) { c.h("JCoreGobal", "Remote Service bind failed :" + th); } } } }