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

Commit f408648a authored by James Lemieux's avatar James Lemieux
Browse files

Tolerate exceptions while probing for settings that silence alarms

Bug: 32196863

One of the probes checks if the system default alarm ringtone is unset.
On some versions of android this can actually *cause* the system to
attempt to initialize that setting, which in turn fails because the clock
app does not request the WRITE_SETTINGS permission.

Change-Id: I36437e581ce668c786b5d66da0920a5f9da8014f
parent b2c693e8
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -529,7 +529,12 @@ public class DeskClock extends BaseActivity
    }

    private boolean isSystemAlarmRingtoneSilent() {
        try {
            return RingtoneManager.getActualDefaultRingtoneUri(this, TYPE_ALARM) == null;
        } catch (Exception e) {
            // Since this is purely informational, avoid crashing the app.
            return false;
        }
    }

    private void showSilentRingtoneSnackbar() {
@@ -548,7 +553,12 @@ public class DeskClock extends BaseActivity
    }

    private boolean isAlarmStreamMuted() {
        try {
            return mAudioManager.getStreamVolume(STREAM_ALARM) <= 0;
        } catch (Exception e) {
            // Since this is purely informational, avoid crashing the app.
            return false;
        }
    }

    private void showAlarmVolumeMutedSnackbar() {
@@ -572,7 +582,13 @@ public class DeskClock extends BaseActivity
        if (!Utils.isMOrLater()) {
            return false;
        }

        try {
            return mNotificationManager.getCurrentInterruptionFilter() == INTERRUPTION_FILTER_NONE;
        } catch (Exception e) {
            // Since this is purely informational, avoid crashing the app.
            return false;
        }
    }

    private void showDoNotDisturbIsBlockingAlarmsSnackbar() {
@@ -805,7 +821,7 @@ public class DeskClock extends BaseActivity
        private final FragmentManager mFragmentManager;
        private final Context mContext;

        public TabFragmentAdapter(AppCompatActivity activity) {
        TabFragmentAdapter(AppCompatActivity activity) {
            super(activity.getFragmentManager());
            mContext = activity;
            mFragmentManager = activity.getFragmentManager();