Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 914793c5 authored by Luofan Chen's avatar Luofan Chen
Browse files

sounds: Use silent if URI returned by ringtone picker is null

Based on RingtoneManager's documentation [1], the EXTRA_RINGTONE_PICKED_URI
will be null if the "Silent" item was picked.

[1]: https://developer.android.com/reference/kotlin/android/media/RingtoneManager#EXTRA_RINGTONE_PICKED_URI:kotlin.String

Change-Id: I5898d64d898d0762c3a8836848f956d876a27d5c
parent 0e05a8f7
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -206,6 +206,12 @@ public class ChargingSoundsSettings extends SettingsPreferenceFragment {
                resultCode == Activity.RESULT_OK) {
            Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);

            if (uri == null) {
                updateChargingSounds(RINGTONE_SILENT_URI_STRING,
                        requestCode == REQUEST_CODE_WIRELESS_CHARGING_SOUND);
                return;
            }

            String mimeType = getContext().getContentResolver().getType(uri);
            if (mimeType == null) {
                Log.e(TAG, "call to updateChargingSounds for URI:" + uri
@@ -219,7 +225,7 @@ public class ChargingSoundsSettings extends SettingsPreferenceFragment {
                return;
            }

            updateChargingSounds(uri != null ? uri.toString() : null,
            updateChargingSounds(uri.toString(),
                    requestCode == REQUEST_CODE_WIRELESS_CHARGING_SOUND);
        }
    }