incorrect merge
This commit is contained in:
parent
95b44b493a
commit
e2aeb0af70
1 changed files with 32 additions and 22 deletions
|
@ -11,23 +11,32 @@ import android.media.AudioManager;
|
|||
/**
|
||||
* This helper class allows API level 8 calls to be isolated from the rest of the app. This class is only be instantiated on OS versions
|
||||
* which support it.
|
||||
*
|
||||
*
|
||||
* @author genly
|
||||
*/
|
||||
public class AudioFocusHelperImpl implements AudioManager.OnAudioFocusChangeListener, AudioFocusHelper {
|
||||
private static final Log log = PlatformUtil.getLog(AudioFocusHelperImpl.class);
|
||||
|
||||
@Override
|
||||
public boolean requestFocus(Context context, int streamType) {
|
||||
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this, streamType,
|
||||
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
|
||||
}
|
||||
public class AudioFocusHelperImpl implements AudioManager.OnAudioFocusChangeListener, AudioFocusHelper
|
||||
{
|
||||
private static final Log log = PlatformUtil.getLog(AudioFocusHelperImpl.class);
|
||||
|
||||
@Override
|
||||
public boolean abandonFocus(Context context, int streamType) {
|
||||
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
if (((OsmandApplication)context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get())
|
||||
@Override
|
||||
public boolean requestFocus(Context context, int streamType)
|
||||
{
|
||||
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
if (((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get())
|
||||
{
|
||||
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this, streamType, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean abandonFocus(Context context, int streamType)
|
||||
{
|
||||
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
if (((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get())
|
||||
{
|
||||
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this);
|
||||
}
|
||||
|
@ -35,13 +44,14 @@ public class AudioFocusHelperImpl implements AudioManager.OnAudioFocusChangeList
|
|||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAudioFocusChange(int focusChange) {
|
||||
// Basically we ignore audio focus changes. There's not much we can do when we have interrupted audio
|
||||
// for our speech, and we in turn get interrupted. Ignore it until a scenario comes up which gives us
|
||||
// reason to change this strategy.
|
||||
log.error("MediaCommandPlayerImpl.onAudioFocusChange(): Unexpected audio focus change: " + focusChange);
|
||||
}
|
||||
@Override
|
||||
public void onAudioFocusChange(int focusChange)
|
||||
{
|
||||
// Basically we ignore audio focus changes. There's not much we can do when we have interrupted audio
|
||||
// for our speech, and we in turn get interrupted. Ignore it until a scenario comes up which gives us
|
||||
// reason to change this strategy.
|
||||
log.error("MediaCommandPlayerImpl.onAudioFocusChange(): Unexpected audio focus change: " + focusChange);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue