Fixed: Do not setup plugin and crash notification channel on API < 24 since NotificationManager.IMPORTANCE_HIGH requires API 24

This commit is contained in:
agnostic-apollo
2022-05-29 06:54:01 +05:00
parent b04f209f17
commit 30cb848639
2 changed files with 4 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.Environment; import android.os.Environment;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@@ -402,6 +403,7 @@ public class TermuxCrashUtils implements CrashHandler.CrashHandlerClient {
* @param context The {@link Context} for operations. * @param context The {@link Context} for operations.
*/ */
public static void setupCrashReportsNotificationChannel(final Context context) { public static void setupCrashReportsNotificationChannel(final Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
NotificationUtils.setupNotificationChannel(context, TermuxConstants.TERMUX_CRASH_REPORTS_NOTIFICATION_CHANNEL_ID, NotificationUtils.setupNotificationChannel(context, TermuxConstants.TERMUX_CRASH_REPORTS_NOTIFICATION_CHANNEL_ID,
TermuxConstants.TERMUX_CRASH_REPORTS_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); TermuxConstants.TERMUX_CRASH_REPORTS_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
} }

View File

@@ -4,6 +4,7 @@ import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Environment; import android.os.Environment;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -415,6 +416,7 @@ public class TermuxPluginUtils {
* @param context The {@link Context} for operations. * @param context The {@link Context} for operations.
*/ */
public static void setupPluginCommandErrorsNotificationChannel(final Context context) { public static void setupPluginCommandErrorsNotificationChannel(final Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
NotificationUtils.setupNotificationChannel(context, TermuxConstants.TERMUX_PLUGIN_COMMAND_ERRORS_NOTIFICATION_CHANNEL_ID, NotificationUtils.setupNotificationChannel(context, TermuxConstants.TERMUX_PLUGIN_COMMAND_ERRORS_NOTIFICATION_CHANNEL_ID,
TermuxConstants.TERMUX_PLUGIN_COMMAND_ERRORS_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); TermuxConstants.TERMUX_PLUGIN_COMMAND_ERRORS_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
} }