package cn.jiguang.d; import android.app.Application; import android.content.Context; import android.content.Intent; import android.os.Build; import android.text.TextUtils; import cn.jiguang.analytics.page.ActivityLifecycle; import cn.jiguang.api.JCoreManager; import cn.jiguang.aq.c; import cn.jiguang.f.f; import cn.jiguang.g.b; import cn.jiguang.internal.ActionManager; import cn.jiguang.internal.JConstants; import java.util.HashMap; import org.json.JSONException; import org.json.JSONObject; public class a { public static Object a() { return ActionManager.getActionMap(); } public static JSONObject a(Context context, String str) { try { if (TextUtils.isEmpty(str)) { c.c("JBridgeHelper", "file_name is null , give up read "); return null; } String d = cn.jiguang.f.c.d(cn.jiguang.f.c.a(context, str)); if (!f.a(d)) { return new JSONObject(d.trim()); } c.c("JBridgeHelper", "read String is empty"); return null; } catch (Throwable th) { c.c("JBridgeHelper", "can't build " + str + " into JsonObject, give up read :" + th); return null; } } public static JSONObject a(Context context, JSONObject jSONObject, String str) { if (jSONObject == null) { jSONObject = new JSONObject(); } try { jSONObject.put("itime", b.b(context)); jSONObject.put("type", str); jSONObject.put("account_id", b.a(context, cn.jiguang.g.a.m())); } catch (JSONException e) { c.g("JBridgeHelper", "fillBase exception:" + e); } return jSONObject; } public static synchronized void a(Context context) { String str; String str2; synchronized (a.class) { try { if (JConstants.isInstrumentationHookFailed && Build.VERSION.SDK_INT >= 14 && (context instanceof Application)) { String a = cn.jiguang.f.a.a(context); String packageName = context.getPackageName(); if (a == null || packageName == null || !context.getPackageName().equals(a)) { str = "JBridgeHelper"; str2 = "need not registerActivityLifecycleCallbacks in other process :" + a; } else { JConstants.isInstrumentationHookFailed = false; ((Application) context).registerActivityLifecycleCallbacks(new ActivityLifecycle()); str = "JBridgeHelper"; str2 = "registerActivityLifecycleCallbacks in main process,packageName:" + packageName + ",currentProcessName:" + a; } c.c(str, str2); } } catch (Throwable th) { c.h("JBridgeHelper", "registerActivityLifecycleCallbacks failed:" + th); JConstants.isInstrumentationHookFailed = true; } } return; } public static void a(Context context, Intent intent) { if (intent != null) { try { if ("asm".equals(intent.getAction())) { JCoreManager.onEvent(context, JConstants.SDK_TYPE, 3, "asm", intent.getExtras(), new Object[0]); return; } } catch (Throwable th) { c.g("JBridgeHelper", "shareActionRun error:" + th.getMessage()); return; } } StringBuilder sb = new StringBuilder(); sb.append("shareActionRun intent error:"); sb.append(intent == null ? "null" : intent.getAction()); c.c("JBridgeHelper", sb.toString()); } public static void a(Context context, Object obj) { JCoreManager.onEvent(context, JConstants.SDK_TYPE, 14, null, null, obj); } public static void a(String str, String str2) { ActionManager.getInstance().addAction(str, str2); } public static String b(Context context) { return (String) b.a(context, cn.jiguang.g.a.d()); } public static String c(Context context) { return (String) b.b(context, cn.jiguang.g.a.l()); } public static String d(Context context) { return (String) b.a(context, cn.jiguang.g.a.m()); } public static String e(Context context) { return cn.jiguang.ap.a.a(context); } public static long f(Context context) { return ((Long) b.a(context, cn.jiguang.g.a.c())).longValue(); } public static String g(Context context) { return cn.jiguang.ap.a.c(context); } public static String h(Context context) { return (String) b.a(context, cn.jiguang.g.a.a()); } public static String i(Context context) { return (String) b.a(context, cn.jiguang.g.a.e()); } public static Object j(Context context) { HashMap hashMap = new HashMap(); long longValue = ((Long) b.a(context, cn.jiguang.g.a.j())).longValue(); int intValue = ((Integer) b.a(context, cn.jiguang.g.a.k())).intValue(); hashMap.put("uuid", (String) b.a(context, cn.jiguang.g.a.i())); hashMap.put("ct", Long.valueOf(longValue)); hashMap.put("state", Integer.valueOf(intValue)); return hashMap; } public static int k(Context context) { return ((Integer) b.a(context, cn.jiguang.g.a.f())).intValue(); } public static boolean l(Context context) { c.c("JBridgeHelper", "canShowLbsPermissionDialog"); Boolean bool = (Boolean) b.a(context, cn.jiguang.g.a.z()); if (bool == null || bool.booleanValue()) { long longValue = ((Long) b.a(context, cn.jiguang.g.a.y())).longValue(); long longValue2 = ((Long) b.a(context, cn.jiguang.g.a.x())).longValue(); c.c("JBridgeHelper", "lbs permission dialog shield, firstInit=" + longValue2 + ", delay=" + longValue); if (longValue2 > 0) { return longValue <= 0 || System.currentTimeMillis() > longValue2 + longValue; } b.a(context, cn.jiguang.g.a.x().a(Long.valueOf(System.currentTimeMillis()))); return longValue <= 0; } c.d("JBridgeHelper", "lbs disable"); return false; } public static int m(Context context) { return ((Integer) b.a(context, cn.jiguang.g.a.k())).intValue(); } }