package Y0;

import android.app.ActivityManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
import com.seewo.hiddenapi.g;
import java.util.List;
import okhttp3.HttpUrl;

/* JADX INFO: loaded from: classes.dex */
public abstract class a {
    public static void a(Context context) {
        com.seewo.hiddenapi.c.c(context, new Intent("com.cvte.action.ANYMARK.close"), g.f3343c);
    }

    private static String b() {
        return k(null) ? "com.seewo.easimark.MarkActivity" : com.seewo.vcommons.data.d.e("sys.current.visible.activity", null);
    }

    public static String c(Context context) {
        String strB = b();
        if (strB != null && !strB.isEmpty()) {
            return strB;
        }
        List<ActivityManager.RunningTaskInfo> runningTasks = ((ActivityManager) context.getSystemService("activity")).getRunningTasks(1);
        if (runningTasks == null || runningTasks.isEmpty()) {
            return null;
        }
        return runningTasks.get(0).topActivity.getClassName();
    }

    private static void d(Context context, Intent intent) {
        if (3 == intent.getIntExtra("KEY_MARK_START_TYPE", 4)) {
            context.sendBroadcast(new Intent("com.cvte.action.ANYMARK.resume"));
        }
    }

    public static boolean e(Context context, String str) {
        String strC = c(context);
        if (strC == null || strC.isEmpty()) {
            return false;
        }
        return strC.equals(str);
    }

    public static boolean f(Context context, String str) {
        if (str != null && !HttpUrl.FRAGMENT_ENCODE_SET.equals(str)) {
            try {
                return context.getPackageManager().getApplicationEnabledSetting(str) != 2;
            } catch (Exception unused) {
                Log.i("ActivityUtils", str + " doesn't have label");
            }
        }
        return false;
    }

    public static boolean g(Context context, String str) {
        if (str != null && !HttpUrl.FRAGMENT_ENCODE_SET.equals(str)) {
            try {
                int applicationEnabledSetting = context.getPackageManager().getApplicationEnabledSetting(str);
                return (applicationEnabledSetting == 2 || applicationEnabledSetting == 3) ? false : true;
            } catch (Exception unused) {
                Log.i("ActivityUtils", str + " doesn't have label");
            }
        }
        return false;
    }

    public static boolean h(Context context) {
        return e(context, "com.seewo.easinote.PlainActivity") || e(context, "com.seewo.easinote.PlainWhiteboardActivity") || e(context, "com.seewo.easinote.PlainPairModeActivity") || (com.seewo.vcommons.data.d.g() & 1) == 1;
    }

    public static boolean i(Context context) {
        return e(context, "com.seewo.easipallet.MainActivity") || (com.seewo.vcommons.data.d.g() & 32) == 32;
    }

    public static boolean j(Context context) {
        return e(context, "com.seewo.freezescreen.activity.FreezeActivity") || m(context, "com.seewo.freezescreen.service.FreezeScreenService");
    }

    public static boolean k(Context context) {
        return (com.seewo.vcommons.data.d.g() & 2) == 2;
    }

    public static boolean l() {
        float f2;
        try {
            f2 = Float.parseFloat(com.seewo.vcommons.data.d.d("persist.sys.easinote.version"));
        } catch (Exception e2) {
            Log.e("ActivityUtils", "isNoteVersionLargeThan2 parse noteVersion fail ", e2);
            f2 = 0.0f;
        }
        return Float.compare(f2, 2.0f) >= 0;
    }

    public static boolean m(Context context, String str) {
        List<ActivityManager.RunningServiceInfo> runningServices = ((ActivityManager) context.getSystemService("activity")).getRunningServices(Integer.MAX_VALUE);
        for (int i2 = 0; i2 < runningServices.size(); i2++) {
            if (runningServices.get(i2).service.getClassName().equals(str)) {
                return true;
            }
        }
        return false;
    }

    public static void n(Context context, String str, boolean z2) {
        try {
            context.getPackageManager().setApplicationEnabledSetting(str, z2 ? 0 : 2, 0);
        } catch (Exception unused) {
            Log.i("ActivityUtils", str + " doesn't have label");
        }
    }

    public static boolean o(Context context, Intent intent) {
        intent.setFlags(270532608);
        try {
            context.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException e2) {
            Log.d("ActivityUtils", "ActivityNotFoundException when startActivitySafely", e2);
            return false;
        }
    }

    public static boolean p(Context context, String str, String str2) {
        ComponentName componentName = new ComponentName(str, str2);
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.LAUNCHER");
        intent.setComponent(componentName);
        intent.setFlags(270532608);
        try {
            context.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException e2) {
            Log.d("ActivityUtils", "catch a ActivityNotFoundException when start " + str + " activity: " + str2, e2);
            return false;
        } catch (SecurityException e3) {
            Log.d("ActivityUtils", "catch a SecurityException when startActivitySafely", e3);
            return false;
        }
    }

    public static boolean q(Context context) {
        Intent intent = new Intent("com.seewo.easinote");
        intent.setFlags(268435456);
        try {
            context.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException e2) {
            Log.d("ActivityUtils", "catch a ActivityNotFoundException when start ", e2);
            return false;
        } catch (SecurityException e3) {
            Log.d("ActivityUtils", "catch a SecurityException when startActivitySafely", e3);
            return false;
        }
    }

    public static void r(Context context, Intent intent) {
        if (k(context)) {
            d(context, intent);
            return;
        }
        intent.setComponent(new ComponentName("com.seewo.easimark", "com.seewo.easimark.MarkService"));
        try {
            com.seewo.hiddenapi.c.e(context, intent, g.f3343c);
        } catch (Exception e2) {
            Log.e("ActivityUtils", "Exception", e2);
            Toast.makeText(context, "can't start application.", 0).show();
        }
    }
}
