package com.helpshift.util; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import androidx.core.app.NotificationManagerCompat; import androidx.core.content.ContextCompat; import com.helpshift.activities.HSMainActivity; import com.helpshift.log.HSLogger; /* loaded from: classes3.dex */ public abstract class ApplicationUtil { public static boolean isApplicationInDebugMode(Context context) { return (context.getApplicationInfo().flags & 2) != 0; } public static boolean isPermissionGranted(Context context, String str) { try { return ContextCompat.checkSelfPermission(context, str) == 0; } catch (Exception e) { HSLogger.d("AppUtil", "Error checking for permission : " + str, e); return false; } } public static void showNotification(Context context, Notification notification, Class cls) { if (notification == null) { HSLogger.d("AppUtil", "notification is null, not showing."); return; } NotificationManager notificationManager = getNotificationManager(context); if (notificationManager == null) { HSLogger.d("AppUtil", "NotificationManager is null, not showing."); return; } try { boolean areNotificationsEnabled = NotificationManagerCompat.from(context).areNotificationsEnabled(); HSLogger.d("AppUtil", "areNotificationAllowed : " + areNotificationsEnabled); if (areNotificationsEnabled) { String generateNotificationTag = generateNotificationTag(cls); HSLogger.d("AppUtil", "Showing notification : Tag : " + generateNotificationTag); notificationManager.notify(generateNotificationTag, 121, notification); } } catch (Exception e) { HSLogger.e("AppUtil", "Error showing notification", e); } } public static NotificationManager getNotificationManager(Context context) { try { return (NotificationManager) context.getSystemService("notification"); } catch (Exception e) { HSLogger.e("AppUtil", "Unable to get notification manager from System service", e); return null; } } public static int getLogoResourceValue(Context context) { int i = context.getApplicationInfo().logo; return i == 0 ? context.getApplicationInfo().icon : i; } public static int getTargetSDKVersion(Context context) { try { return context.getApplicationInfo().targetSdkVersion; } catch (Exception e) { HSLogger.d("AppUtil", "Target SDK version not found", e); return 0; } } public static void cancelNotification(Context context) { HSLogger.d("AppUtil", "Cancelling notification"); NotificationManager notificationManager = getNotificationManager(context); if (notificationManager != null) { notificationManager.cancel(generateNotificationTag(HSMainActivity.class), 121); } } public static int getResourceIdFromName(Context context, String str, String str2, String str3) { return context.getResources().getIdentifier(str, str2, str3); } public static Intent getLaunchIntent(Context context, String str) { try { return context.getPackageManager().getLaunchIntentForPackage(str); } catch (Exception e) { HSLogger.e("AppUtil", "Error getting launch activity for package : " + str, e); return null; } } public static String generateNotificationTag(Class cls) { return "hsft_notification_tag_" + cls.getName(); } }