package com.efs.sdk.launch; import android.app.ActivityManager; import android.content.Context; import android.content.SharedPreferences; import android.os.Process; import android.text.TextUtils; import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Iterator; import java.util.List; public final class c { private static String a = ""; public static String a(Context context) { Class<?> cls; Method method; if (context == null) { return null; } try { cls = Class.forName("com.umeng.commonsdk.UMConfigure"); } catch (ClassNotFoundException unused) { cls = null; } if (cls == null) { return null; } try { method = cls.getMethod("getUMIDString", Context.class); } catch (NoSuchMethodException unused2) { method = null; } if (method == null) { return null; } try { Object invoke = method.invoke(null, context); if (invoke != null) { return invoke.toString(); } return null; } catch (IllegalAccessException | InvocationTargetException unused3) { return null; } } public static void a(Context context, String str) { SharedPreferences sharedPreferences; SharedPreferences.Editor edit; if (context != null && str != null && !TextUtils.isEmpty(str) && (sharedPreferences = context.getApplicationContext().getSharedPreferences("efs_launch", 0)) != null && (edit = sharedPreferences.edit()) != null) { edit.putString("first_launch_cache", str); edit.commit(); } } public static String b(Context context) { SharedPreferences sharedPreferences; if (context == null || (sharedPreferences = context.getApplicationContext().getSharedPreferences("efs_launch", 0)) == null) { return null; } return sharedPreferences.getString("first_launch_cache", null); } public static void c(Context context) { SharedPreferences sharedPreferences; SharedPreferences.Editor edit; if (context != null && (sharedPreferences = context.getApplicationContext().getSharedPreferences("efs_launch", 0)) != null && (edit = sharedPreferences.edit()) != null) { edit.putString("first_launch_cache", null); edit.commit(); } } public static boolean d(Context context) { SharedPreferences sharedPreferences; SharedPreferences.Editor edit; SharedPreferences sharedPreferences2; if ((context == null || (sharedPreferences2 = context.getApplicationContext().getSharedPreferences("efs_launch", 0)) == null) ? false : sharedPreferences2.getBoolean("is_install", false)) { return false; } if (!(context == null || (sharedPreferences = context.getApplicationContext().getSharedPreferences("efs_launch", 0)) == null || (edit = sharedPreferences.edit()) == null)) { edit.putBoolean("is_install", true); edit.commit(); } return true; } public static boolean e(Context context) { try { String f = f(context); String packageName = context.getApplicationContext().getPackageName(); return !TextUtils.isEmpty(f) && !TextUtils.isEmpty(packageName) && f.equals(packageName); } catch (Exception e) { e.printStackTrace(); return false; } } private static String f(Context context) { List<ActivityManager.RunningAppProcessInfo> runningAppProcesses; if (TextUtils.isEmpty(a)) { try { int myPid = Process.myPid(); ActivityManager activityManager = (ActivityManager) context.getSystemService(TTDownloadField.TT_ACTIVITY); if (activityManager != null && (runningAppProcesses = activityManager.getRunningAppProcesses()) != null && runningAppProcesses.size() > 0) { Iterator<ActivityManager.RunningAppProcessInfo> it = runningAppProcesses.iterator(); while (true) { if (!it.hasNext()) { break; } ActivityManager.RunningAppProcessInfo next = it.next(); if (next.pid == myPid) { a = next.processName; break; } } } } catch (Throwable unused) { } } return a; } }