- Simplify the audio, since we don't trigger the alarm if in a call.

This commit is contained in:
Timothy Allen 2014-04-14 00:10:15 +02:00
parent 36b796fd13
commit fb886aabe9

View File

@ -27,7 +27,6 @@ public class AlarmKlaxon {
/**
*
* TODO allow user to select alarm tone
* TODO prevent alarm from being ignored or snoozing if a call comes in?
*
*/
@ -37,7 +36,6 @@ public class AlarmKlaxon {
telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
initialCallState = telephonyManager.getCallState();
boolean inTelephoneCall = initialCallState != TelephonyManager.CALL_STATE_IDLE;
phoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String ignored) {
@ -46,7 +44,11 @@ public class AlarmKlaxon {
// which kills the alarm. Check against the initial call state so
// we don't kill the alarm during a call.
if (state != TelephonyManager.CALL_STATE_IDLE && state != initialCallState) {
stopAudio(context);
if (mediaPlayer != null) {
mediaPlayer.setVolume(IN_CALL_VOLUME, IN_CALL_VOLUME);
}
// or just stop the audio entirely...
//stopAudio(context);
}
}
};
@ -68,14 +70,8 @@ public class AlarmKlaxon {
});
try {
if (inTelephoneCall) {
Log.d("AlarmKlaxon", "Using the in-call alarm");
mediaPlayer.setVolume(IN_CALL_VOLUME, IN_CALL_VOLUME);
setDataSourceFromResource(context, mediaPlayer, R.raw.in_call_alarm);
} else {
mediaPlayer.setDataSource(context, alarmNoise);
startAudio(context);
}
mediaPlayer.setDataSource(context, alarmNoise);
startAudio(context);
} catch (Exception ex) {
// The alarmNoise may be on the sd card which could be busy right
// now. Use the fallback ringtone.