proper AudioManager constant

This commit is contained in:
sonora 2020-03-28 20:46:49 +01:00
parent 52b40b075d
commit 0ddf6d6073
11 changed files with 27 additions and 27 deletions

View file

@ -2060,7 +2060,7 @@ public class OsmandSettings {
public final OsmandPreference<Integer> LEVEL_TO_SWITCH_VECTOR_RASTER = new IntPreference("level_to_switch_vector_raster", 1).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Integer> AUDIO_STREAM_GUIDANCE = new IntPreference("audio_stream", 3/*AudioManager.STREAM_MUSIC*/) {
public final OsmandPreference<Integer> AUDIO_MANAGER_STREAM = new IntPreference("audio_stream", 3/*AudioManager.STREAM_MUSIC*/) {
@Override
protected boolean setValue(Object prefs, Integer stream) {
boolean valueSaved = super.setValue(prefs, stream);

View file

@ -798,8 +798,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
// for voice navigation
ApplicationMode routingAppMode = getRoutingHelper().getAppMode();
if (routingAppMode != null && settings.AUDIO_STREAM_GUIDANCE.getModeValue(routingAppMode) != null) {
setVolumeControlStream(settings.AUDIO_STREAM_GUIDANCE.getModeValue(routingAppMode));
if (routingAppMode != null && settings.AUDIO_MANAGER_STREAM.getModeValue(routingAppMode) != null) {
setVolumeControlStream(settings.AUDIO_MANAGER_STREAM.getModeValue(routingAppMode));
} else {
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}

View file

@ -264,7 +264,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
AudioManager.STREAM_NOTIFICATION, AudioManager.STREAM_VOICE_CALL};
//AudioManager.USE_DEFAULT_STREAM_TYPE};
ListPreference lp = createListPreference(
settings.AUDIO_STREAM_GUIDANCE, streamTypes, streamIntTypes , R.string.choose_audio_stream,
settings.AUDIO_MANAGER_STREAM, streamTypes, streamIntTypes , R.string.choose_audio_stream,
R.string.choose_audio_stream_descr);
final Preference.OnPreferenceChangeListener prev = lp.getOnPreferenceChangeListener();
lp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@ -274,11 +274,11 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
prev.onPreferenceChange(preference, newValue);
CommandPlayer player = getMyApplication().getPlayer();
if (player != null) {
player.updateAudioStream(settings.AUDIO_STREAM_GUIDANCE.get());
player.updateAudioStream(settings.AUDIO_MANAGER_STREAM.get());
}
// Sync corresponding AUDIO_USAGE value
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
int stream = settings.AUDIO_STREAM_GUIDANCE.getModeValue(mode);
int stream = settings.AUDIO_MANAGER_STREAM.getModeValue(mode);
if (stream == AudioManager.STREAM_MUSIC) {
settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE);
} else if (stream == AudioManager.STREAM_NOTIFICATION) {
@ -288,7 +288,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
// Sync DEFAULT value with CAR value, as we have other way to set it for now
settings.AUDIO_STREAM_GUIDANCE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_STREAM_GUIDANCE.getModeValue(ApplicationMode.CAR));
settings.AUDIO_MANAGER_STREAM.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_MANAGER_STREAM.getModeValue(ApplicationMode.CAR));
settings.AUDIO_USAGE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_USAGE.getModeValue(ApplicationMode.CAR));
return true;
}

View file

@ -1223,7 +1223,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
private void muteStreamMusicAndOutputGuidance() {
AudioManager am = (AudioManager)app.getSystemService(Context.AUDIO_SERVICE);
int voiceGuidanceOutput = app.getSettings().AUDIO_STREAM_GUIDANCE.get();
int voiceGuidanceOutput = app.getSettings().AUDIO_MANAGER_STREAM.get();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
am.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_MUTE, 0);
if (voiceGuidanceOutput != AudioManager.STREAM_MUSIC)
@ -1237,7 +1237,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
private void unmuteStreamMusicAndOutputGuidance() {
AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
int voiceGuidanceOutput = app.getSettings().AUDIO_STREAM_GUIDANCE.get();
int voiceGuidanceOutput = app.getSettings().AUDIO_MANAGER_STREAM.get();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
am.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_UNMUTE, 0);
if (voiceGuidanceOutput != AudioManager.STREAM_MUSIC)

View file

@ -125,14 +125,14 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
String v ="";
v += " \u25CF App profile: " + ((OsmandApplication) getApplication()).getSettings().APPLICATION_MODE.get().getStringKey();
if (((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get() == 3) {
if (((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get() == 3) {
v += "\n \u25CF Voice guidance output: Media/music audio";
} else if (((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get() == 5) {
} else if (((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get() == 5) {
v += "\n \u25CF Voice guidance output: Notification audio";
} else if (((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) {
} else if (((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get() == 0) {
v += "\n \u25CF Voice guidance output: Phone call audio";
} else {
v += "\n \u25CF Voice guidance output: " + ((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get();
v += "\n \u25CF Voice guidance output: " + ((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get();
}
v += "\n \u25CF OsmAnd voice: " + osmandVoice;
@ -141,7 +141,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
v += "\n \u25CF TTS voice language availability: " + TTSCommandPlayerImpl.getTtsVoiceStatus();
v += "\n \u25CF TTS voice actually used: " + TTSCommandPlayerImpl.getTtsVoiceUsed();
if (((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) {
if (((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get() == 0) {
v += "\n \u25CF BT SCO: " + AbstractPrologCommandPlayer.btScoInit;
} else {
v += "\n \u25CF BT SCO: The current app profile is not set to use 'Phone call audio'.";
@ -282,7 +282,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
Toast.makeText(TestVoiceActivity.this, "Info refreshed.", Toast.LENGTH_LONG).show();
}
if (description.startsWith("\u25BA (11.2)")) {
if (((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) {
if (((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get() == 0) {
if (((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.get() == 1000) {
((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.set(1500);
} else if (((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.get() == 1500) {

View file

@ -203,7 +203,7 @@ public class VoiceRouter {
}
// Trigger close prompts earlier if delayed for BT SCO connection establishment
if ((settings.AUDIO_STREAM_GUIDANCE.getModeValue(router.getAppMode()) == 0) && !AbstractPrologCommandPlayer.btScoStatus) {
if ((settings.AUDIO_MANAGER_STREAM.getModeValue(router.getAppMode()) == 0) && !AbstractPrologCommandPlayer.btScoStatus) {
btScoDelayDistance = currentSpeed * (double) settings.BT_SCO_DELAY.get() / 1000;
}

View file

@ -199,7 +199,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
};
//AudioManager.USE_DEFAULT_STREAM_TYPE};
ListPreferenceEx audioStreamGuidance = createListPreferenceEx(settings.AUDIO_STREAM_GUIDANCE.getId(), streamTypes, streamIntTypes, R.string.choose_audio_stream, R.layout.preference_with_descr);
ListPreferenceEx audioStreamGuidance = createListPreferenceEx(settings.AUDIO_MANAGER_STREAM.getId(), streamTypes, streamIntTypes, R.string.choose_audio_stream, R.layout.preference_with_descr);
getPreferenceScreen().addPreference(audioStreamGuidance);
}
@ -285,13 +285,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
return true;
}
}
if (prefId.equals(settings.AUDIO_STREAM_GUIDANCE.getId())) {
if (prefId.equals(settings.AUDIO_MANAGER_STREAM.getId())) {
// Sync DEFAULT value with CAR value, as we have other way to set it for now
if (getSelectedAppMode().equals(ApplicationMode.CAR) && newValue instanceof Integer) {
settings.AUDIO_STREAM_GUIDANCE.setModeValue(ApplicationMode.DEFAULT, (Integer) newValue);
settings.AUDIO_MANAGER_STREAM.setModeValue(ApplicationMode.DEFAULT, (Integer) newValue);
} else {
settings.AUDIO_STREAM_GUIDANCE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_STREAM_GUIDANCE.getModeValue(ApplicationMode.CAR));
settings.AUDIO_MANAGER_STREAM.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_MANAGER_STREAM.getModeValue(ApplicationMode.CAR));
}
settings.AUDIO_USAGE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_USAGE.getModeValue(ApplicationMode.CAR));

View file

@ -77,7 +77,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
long time = System.currentTimeMillis();
this.ctx = ctx;
this.streamType = ctx.getSettings().AUDIO_STREAM_GUIDANCE.getModeValue(applicationMode);
this.streamType = ctx.getSettings().AUDIO_MANAGER_STREAM.getModeValue(applicationMode);
initVoiceDir(voiceProvider);
if (voiceDir != null && (MediaCommandPlayerImpl.isMyData(voiceDir) || TTSCommandPlayerImpl.isMyData(voiceDir))) {
if (log.isInfoEnabled()) {
@ -294,7 +294,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
if (mAudioFocusHelper != null && ctx != null) {
boolean audioFocusGranted = mAudioFocusHelper.requestFocus(ctx, applicationMode, streamType);
// If AudioManager.STREAM_VOICE_CALL try using BT SCO:
if (audioFocusGranted && ctx.getSettings().AUDIO_STREAM_GUIDANCE.getModeValue(applicationMode) == 0) {
if (audioFocusGranted && ctx.getSettings().AUDIO_MANAGER_STREAM.getModeValue(applicationMode) == 0) {
toggleBtSco(true);
}
}
@ -311,7 +311,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
protected synchronized void abandonAudioFocus() {
log.debug("abandonAudioFocus");
if ((ctx != null && ctx.getSettings().AUDIO_STREAM_GUIDANCE.getModeValue(applicationMode) == 0) || (btScoStatus == true)) {
if ((ctx != null && ctx.getSettings().AUDIO_MANAGER_STREAM.getModeValue(applicationMode) == 0) || (btScoStatus == true)) {
toggleBtSco(false);
}
if (ctx != null && mAudioFocusHelper != null) {

View file

@ -56,7 +56,7 @@ public class JSMediaCommandPlayerImpl extends MediaCommandPlayerImpl {
if (mediaPlayer == null) {
requestAudioFocus();
// Delay first prompt of each batch to allow BT SCO connection being established
if (ctx != null && ctx.getSettings().AUDIO_STREAM_GUIDANCE.getModeValue(getApplicationMode()) == 0) {
if (ctx != null && ctx.getSettings().AUDIO_MANAGER_STREAM.getModeValue(getApplicationMode()) == 0) {
try {
log.debug("Delaying MediaCommandPlayer for BT SCO");
Thread.sleep(ctx.getSettings().BT_SCO_DELAY.get());

View file

@ -88,7 +88,7 @@ public class MediaCommandPlayerImpl extends AbstractPrologCommandPlayer implemen
if (mediaPlayer == null) {
requestAudioFocus();
// Delay first prompt of each batch to allow BT SCO connection being established
if (ctx != null && ctx.getSettings().AUDIO_STREAM_GUIDANCE.getModeValue(getApplicationMode()) == 0) {
if (ctx != null && ctx.getSettings().AUDIO_MANAGER_STREAM.getModeValue(getApplicationMode()) == 0) {
try {
log.debug("Delaying MediaCommandPlayer for BT SCO");
Thread.sleep(ctx.getSettings().BT_SCO_DELAY.get());

View file

@ -88,7 +88,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
cSpeechRate = app.getSettings().SPEECH_RATE.get();
}
initializeEngine(app, ctx);
params.put(TextToSpeech.Engine.KEY_PARAM_STREAM, app.getSettings().AUDIO_STREAM_GUIDANCE
params.put(TextToSpeech.Engine.KEY_PARAM_STREAM, app.getSettings().AUDIO_MANAGER_STREAM
.getModeValue(getApplicationMode()).toString());
}
@ -124,7 +124,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
.build());
}
// Delay first prompt of each batch to allow BT SCO connection being established
if (ctx.getSettings().AUDIO_STREAM_GUIDANCE.getModeValue(getApplicationMode()) == 0) {
if (ctx.getSettings().AUDIO_MANAGER_STREAM.getModeValue(getApplicationMode()) == 0) {
ttsRequests++;
if (android.os.Build.VERSION.SDK_INT < 21) {
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,""+System.currentTimeMillis());