diff --git a/CHANGELOG.md b/CHANGELOG.md index cd1093f9e..658b9fa9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * remove mostly non-telling transport addresses when referring to a contact; the contact's profile gives a much better overview * Disable AEAP to enable us to overhaul some things - there are big changes underway in this area, which will come in a few months +* avoid crash in Notifications preferences if ringtone title can't be read ## v1.56.1 2025-03 diff --git a/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java b/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java index d0ddbe803..2356e89d0 100644 --- a/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java @@ -14,6 +14,7 @@ import android.os.Bundle; import android.os.PowerManager; import android.provider.Settings; import android.text.TextUtils; +import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -31,6 +32,7 @@ import org.thoughtcrime.securesms.util.Prefs; public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragment { + private static final String TAG = NotificationsPreferenceFragment.class.getSimpleName(); private static final int REQUEST_CODE_NOTIFICATION_SELECTED = 1; private CheckBoxPreference ignoreBattery; @@ -159,7 +161,17 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme Ringtone tone = RingtoneManager.getRingtone(getActivity(), value); if (tone != null) { - preference.setSummary(tone.getTitle(getActivity())); + String summary; + try { + summary = tone.getTitle(getActivity()); + } catch (SecurityException e) { + // this could happen in some phones when user selects ringtone from + // external storage and later removes the read from external storage permission + // and later this method is called from initializeRingtoneSummary() + summary = ""; + Log.w(TAG, e); + } + preference.setSummary(summary); } }