Merge pull request #3725 from deltachat/adb/issue-3717

avoid SecurityException in NotificationsPreferenceFragment
This commit is contained in:
adb
2025-04-11 14:30:18 +00:00
committed by GitHub
2 changed files with 14 additions and 1 deletions
+1
View File
@@ -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
@@ -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 = "<no access>";
Log.w(TAG, e);
}
preference.setSummary(summary);
}
}