Clear out checks for SDK < 23 as they're no longer relevant.

This commit is contained in:
Alex Hart
2025-10-31 12:50:47 -03:00
committed by Michelle Tang
parent ab9c8626c0
commit 1d7ae669b6
57 changed files with 137 additions and 387 deletions

View File

@@ -9,14 +9,13 @@ import android.os.Build;
import android.provider.ContactsContract;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.WorkerThread;
import org.signal.core.util.CursorUtil;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.signal.core.util.CursorUtil;
import org.thoughtcrime.securesms.util.ServiceUtil;
import java.util.concurrent.TimeUnit;
@@ -31,8 +30,6 @@ public final class DoNotDisturbUtil {
@WorkerThread
@SuppressLint("SwitchIntDef")
public static boolean shouldDisturbUserWithCall(@NonNull Context context) {
if (Build.VERSION.SDK_INT <= 23) return true;
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
switch (notificationManager.getCurrentInterruptionFilter()) {
@@ -47,8 +44,6 @@ public final class DoNotDisturbUtil {
@WorkerThread
@SuppressLint("SwitchIntDef")
public static boolean shouldDisturbUserWithCall(@NonNull Context context, @NonNull Recipient recipient) {
if (Build.VERSION.SDK_INT <= 23) return true;
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
switch (notificationManager.getCurrentInterruptionFilter()) {
@@ -65,7 +60,6 @@ public final class DoNotDisturbUtil {
}
}
@RequiresApi(23)
private static boolean handlePriority(@NonNull Context context, @NonNull NotificationManager notificationManager, @NonNull Recipient recipient) {
if (Build.VERSION.SDK_INT < 28 && !notificationManager.isNotificationPolicyAccessGranted()) {
Log.w(TAG, "Notification Policy is not granted");

View File

@@ -14,8 +14,8 @@ import com.annimon.stream.Stream;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.notifications.v2.DefaultMessageNotifier;
import org.thoughtcrime.securesms.notifications.v2.ConversationId;
import org.thoughtcrime.securesms.notifications.v2.DefaultMessageNotifier;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.util.BubbleUtil;
import org.thoughtcrime.securesms.util.ConversationUtil;
@@ -53,31 +53,27 @@ public final class NotificationCancellationHelper {
* bubble notifications that do not have unread messages in them.
*/
public static void cancelAllMessageNotifications(@NonNull Context context, @NonNull Set<Integer> stickyNotifications) {
if (Build.VERSION.SDK_INT >= 23) {
try {
NotificationManager notifications = ServiceUtil.getNotificationManager(context);
StatusBarNotification[] activeNotifications = notifications.getActiveNotifications();
int activeCount = 0;
try {
NotificationManager notifications = ServiceUtil.getNotificationManager(context);
StatusBarNotification[] activeNotifications = notifications.getActiveNotifications();
int activeCount = 0;
for (StatusBarNotification activeNotification : activeNotifications) {
if (isSingleThreadNotification(activeNotification)) {
activeCount++;
if (!stickyNotifications.contains(activeNotification.getId()) && cancel(context, activeNotification.getId())) {
activeCount--;
}
for (StatusBarNotification activeNotification : activeNotifications) {
if (isSingleThreadNotification(activeNotification)) {
activeCount++;
if (!stickyNotifications.contains(activeNotification.getId()) && cancel(context, activeNotification.getId())) {
activeCount--;
}
}
if (activeCount == 0) {
cancelLegacy(context, NotificationIds.MESSAGE_SUMMARY);
}
} catch (Throwable e) {
// XXX Appears to be a ROM bug, see #6043
Log.w(TAG, "Canceling all notifications.", e);
ServiceUtil.getNotificationManager(context).cancelAll();
}
} else {
cancelLegacy(context, NotificationIds.MESSAGE_SUMMARY);
if (activeCount == 0) {
cancelLegacy(context, NotificationIds.MESSAGE_SUMMARY);
}
} catch (Throwable e) {
// XXX Appears to be a ROM bug, see #6043
Log.w(TAG, "Canceling all notifications.", e);
ServiceUtil.getNotificationManager(context).cancelAll();
}
}
@@ -110,7 +106,6 @@ public final class NotificationCancellationHelper {
/**
* @return whether this is a non-summary notification that is a member of the NOTIFICATION_GROUP group.
*/
@RequiresApi(23)
private static boolean isSingleThreadNotification(@NonNull StatusBarNotification statusBarNotification) {
return statusBarNotification.getId() != NotificationIds.MESSAGE_SUMMARY &&
Objects.equals(statusBarNotification.getNotification().getGroup(), DefaultMessageNotifier.NOTIFICATION_GROUP);

View File

@@ -5,7 +5,6 @@
package org.thoughtcrime.securesms.notifications
import android.os.Build
import android.text.TextUtils
import androidx.annotation.WorkerThread
import org.signal.core.util.logging.Log
@@ -76,10 +75,6 @@ object SlowNotificationHeuristics {
@JvmStatic
fun shouldPromptBatterySaver(): Boolean {
if (Build.VERSION.SDK_INT < 23) {
return false
}
val remoteEnabled = LocaleRemoteConfig.isBatterySaverPromptEnabled() || LocaleRemoteConfig.isDelayedNotificationPromptEnabled()
if (!remoteEnabled || SignalStore.uiHints.hasDismissedBatterySaverPrompt()) {
return false