package cn.jiguang.o; import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import cn.jiguang.af.a; import cn.jiguang.f.f; import cn.jiguang.internal.JConstants; import java.util.HashMap; @SuppressLint({"CommitPrefEdits"}) public class b { private static SharedPreferences a; private static HashMap<String, Long> b; private static String a(String str, String str2) { return str + str2; } private static void a() { b = new HashMap<>(); b.put(a("JLocation", "_bi"), 900000L); b.put(a("JWakeConfigHelper", "_bi"), Long.valueOf((long) JConstants.HOUR)); b.put(a("JArp", "_ri"), Long.valueOf((long) JConstants.HOUR)); b.put(a("JDeviceBattery", "_ri"), Long.valueOf((long) JConstants.HOUR)); b.put(a("JDevice", "_ri"), Long.valueOf((long) JConstants.DAY)); b.put(a("JLocation", "_ri"), Long.valueOf((long) JConstants.HOUR)); b.put(a("JWakeReport", "_ri"), Long.valueOf((long) JConstants.HOUR)); b.put(a("JAppMovement", "_bi"), Long.valueOf((long) JConstants.HOUR)); b.put(a("JAppAll", "_ri"), 604800000L); b.put(a("JAppSdk", "_ri"), 604800000L); b.put(a("JAppRunning", "_ri"), Long.valueOf((long) JConstants.HOUR)); } public static void a(Context context) { String p = p(context); o(context).edit().putInt(p, o(context).getInt(p, 0) + 1).apply(); } public static void a(Context context, int i) { o(context).edit().putInt("rrat", i).apply(); } public static void a(Context context, long j) { o(context).edit().putLong("copy_time", j).apply(); } public static void a(Context context, String str, int i) { o(context).edit().putInt(a("JType", "ktsv_" + str), i).apply(); } public static void a(Context context, String str, long j) { if (j >= 0) { if (!str.contains("JLocation") || j <= h(context, str)) { String a2 = a(str, "_bi"); a.c("JCommonConfig", "update " + str + " businessInterval:" + j); o(context).edit().putLong(a2, j).apply(); } } } public static void a(Context context, String str, String str2) { o(context).edit().putString(a("JType", str), str2).apply(); } public static void a(Context context, String str, boolean z) { o(context).edit().putBoolean(a(str, "_ace"), z).apply(); } public static void a(Context context, boolean z) { o(context).edit().putBoolean(a("user_wake", "_aue"), z).apply(); } public static boolean a(Context context, String str) { long currentTimeMillis = System.currentTimeMillis(); long d = d(context, str); long e = e(context, str); boolean z = currentTimeMillis - d > e; a.c("JCommonConfig", "is " + str + " businessTime:" + z + ",curTime:" + currentTimeMillis + ",lastBusinessTime:" + d + ",businessInterval:" + e); return z; } private static long b(String str, String str2) { try { return b.get(a(str, str2)).longValue(); } catch (NullPointerException unused) { return 0; } } public static void b(Context context, int i) { o(context).edit().putInt("rrpt", i).apply(); } public static void b(Context context, long j) { o(context).edit().putLong("copy_report_time", j).apply(); } public static void b(Context context, String str, long j) { if (j >= 0) { String a2 = a(str, "_ri"); a.c("JCommonConfig", "update " + str + " reportInterval:" + j); o(context).edit().putLong(a2, j).apply(); } } public static void b(Context context, String str, boolean z) { o(context).edit().putBoolean(a(str, "_aue"), z).apply(); } public static void b(Context context, boolean z) { o(context).edit().putBoolean("JArponceEnable", z).apply(); } public static boolean b(Context context) { return o(context).getBoolean(a("user_wake", "_aue"), true); } public static boolean b(Context context, String str) { long currentTimeMillis = System.currentTimeMillis(); long g = g(context, str); long h = h(context, str); boolean z = currentTimeMillis - g > h; a.c("JCommonConfig", "is " + str + " reportTime:" + z + ",curTime:" + currentTimeMillis + ",lastReportTime:" + g + ",reportInterval:" + h); return z; } public static int c(Context context) { return o(context).getInt("rrat", 1); } public static void c(Context context, String str) { if (!str.contains("JApp") || str.equals("JAppMovement")) { String a2 = a(str, "_blt"); long currentTimeMillis = System.currentTimeMillis(); a.c("JCommonConfig", "update " + str + " lastBusinessTime"); o(context).edit().putLong(a2, currentTimeMillis).apply(); } } public static int d(Context context) { return o(context).getInt("rrpt", 1); } public static long d(Context context, String str) { return o(context).getLong(a(str, "_blt"), 0); } public static long e(Context context, String str) { return o(context).getLong(a(str, "_bi"), b(str, "_bi")); } public static boolean e(Context context) { return o(context).getBoolean("JArponceEnable", false); } public static String f(Context context) { return o(context).getString(a("JLocation", "info"), ""); } public static void f(Context context, String str) { a.c("JCommonConfig", "update " + str + " lastReportTime"); long currentTimeMillis = System.currentTimeMillis(); o(context).edit().putLong(a(str, "_rlt"), currentTimeMillis).apply(); } public static long g(Context context, String str) { return o(context).getLong(a(str, "_rlt"), 0); } public static String g(Context context) { return o(context).getString("JNotificationState", ""); } public static long h(Context context, String str) { return o(context).getLong(a(str, "_ri"), b(str, "_ri")); } public static String h(Context context) { return o(context).getString("JDevicesession", ""); } public static String i(Context context) { return o(context).getString("copy_config", ""); } public static boolean i(Context context, String str) { SharedPreferences o; boolean z; String a2 = a(str, "_ace"); if (str.equals("JArp")) { o = o(context); z = false; } else { o = o(context); z = true; } return o.getBoolean(a2, z); } public static String j(Context context) { return o(context).getString("copy_history", ""); } public static boolean j(Context context, String str) { return o(context).getBoolean(a(str, "_aue"), true); } public static long k(Context context) { return o(context).getLong("copy_time", 0); } public static void k(Context context, String str) { if (!f.a(str)) { String p = p(context); if (p != null && !p.equals(str)) { o(context).edit().remove(p).apply(); } o(context).edit().putString("current_time_key", str).apply(); } } public static int l(Context context, String str) { if (f.a(str)) { return Integer.MAX_VALUE; } return o(context).getInt(str, 0); } public static long l(Context context) { return o(context).getLong("copy_report_time", 0); } public static String m(Context context, String str) { return o(context).getString(a("JType", str), "-1,-1"); } public static void m(Context context) { o(context).edit().remove("copy_config").remove("copy_history").remove("copy_time").remove("copy_report_time").apply(); } public static int n(Context context, String str) { return o(context).getInt(a("JType", "ktsv_" + str), 0); } private static void n(Context context) { a = context.getSharedPreferences("cn.jiguang.common", 0); a(); } private static SharedPreferences o(Context context) { if (a == null) { n(context); } return a; } public static void o(Context context, String str) { o(context).edit().putBoolean(a("JArp", str), true).apply(); } private static String p(Context context) { return o(context).getString("current_time_key", null); } public static boolean p(Context context, String str) { return o(context).getBoolean(a("JArp", str), false); } public static void q(Context context, String str) { o(context).edit().putString(a("JLocation", "info"), str).apply(); } public static void r(Context context, String str) { o(context).edit().putString("JNotificationState", str).apply(); } public static void s(Context context, String str) { a.c("JCommonConfig", "update deviceSession"); o(context).edit().putString("JDevicesession", str).apply(); } public static void t(Context context, String str) { o(context).edit().putString("copy_config", str).apply(); } public static void u(Context context, String str) { o(context).edit().putString("copy_history", str).apply(); } }