package cn.jiguang.bc; import android.content.Context; import android.content.SharedPreferences; import java.util.Random; public class e { private static SharedPreferences a; private static long a(long j) { long j2 = 2; if (j % 2 == 0) { j2 = 1; } return (j + j2) % 32767; } private static long a(Context context, long j) { long j2 = c(context).getLong("next_rid", j); if (j2 == j) { return j2; } long a2 = a(j2); c(context).edit().putLong("next_rid", a2).apply(); return a2; } public static void a(Context context) { a = context.getSharedPreferences("cn.jpush.preferences.support.rid", 0); } public static synchronized long b(Context context) { long a2; synchronized (e.class) { a2 = a(context, -1); if (a2 == -1) { a2 = a((long) Math.abs(new Random().nextInt(32767))); c(context).edit().putLong("next_rid", a2).apply(); } } return a2; } private static SharedPreferences c(Context context) { if (a == null) { a(context); } return a; } }