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

Commit 168db9c6 authored by Sean Stout's avatar Sean Stout
Browse files

Catch RingtoneManager#getCursor exceptions - DO NOT MERGE

Bug: 29247779
Test: manual - make sure no crashes occur due to RingtoneManager

RingtoneManager#getCursor was capable of occasionally throwing exceptions.
Instead of crashing in these cases, log the error and continue.

Change-Id: I41ab70dffab1bc216a7e6047059d6b53f6e0e7b5
parent b2c693e8
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -336,7 +336,11 @@ public final class RingtonePickerDialogFragment extends DialogFragment implement

            // Force the ringtone manager to load its ringtones. The cursor will be cached
            // internally by the ringtone manager.
            try {
                ringtoneManager.getCursor();
            } catch (Exception e) {
                LogUtils.e("Error getting Ringtone Manager cursor", e);
            }

            return ringtoneManager;
        }
@@ -348,7 +352,11 @@ public final class RingtonePickerDialogFragment extends DialogFragment implement
                    mRingtoneCursor.close();
                }
                mRingtoneManager = ringtoneManager;
                try {
                    mRingtoneCursor = mRingtoneManager.getCursor();
                } catch (Exception e) {
                    LogUtils.e("Error getting Ringtone Manager cursor", e);
                }
            }
            super.deliverResult(ringtoneManager);
        }
@@ -413,7 +421,11 @@ public final class RingtonePickerDialogFragment extends DialogFragment implement
         */
        public RingtoneAdapter setRingtoneManager(RingtoneManager ringtoneManager) {
            mRingtoneManager = ringtoneManager;
            try {
                mRingtoneCursor = ringtoneManager == null ? null : ringtoneManager.getCursor();
            } catch (Exception e) {
                LogUtils.e("Error getting Ringtone Manager cursor", e);
            }
            notifyDataSetChanged();

            return this;