mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1531833 - Add a Java method that enables and disable all that is needed to do audio communication with an earpiece. r=snorp
Differential Revision: https://phabricator.services.mozilla.com/D21735 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
90034d42cc
commit
2867cb1c22
@ -1996,6 +1996,41 @@ public class GeckoAppShell {
|
||||
return Integer.parseInt(prop);
|
||||
}
|
||||
|
||||
static private int sPreviousAudioMode = -2;
|
||||
|
||||
@WrapForJNI(calledFrom = "any")
|
||||
public static void setCommunicationAudioModeOn(final boolean on) {
|
||||
final AudioManager am = (AudioManager)getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
if (am == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sPreviousAudioMode == AudioManager.MODE_INVALID) {
|
||||
sPreviousAudioMode = am.getMode();
|
||||
}
|
||||
|
||||
try {
|
||||
if (on) {
|
||||
Log.e(LOGTAG, "Setting communication mode ON");
|
||||
sPreviousAudioMode = am.getMode();
|
||||
am.startBluetoothSco();
|
||||
am.setBluetoothScoOn(true);
|
||||
am.setMode(AudioManager.MODE_IN_COMMUNICATION);
|
||||
} else {
|
||||
Log.e(LOGTAG, "Setting communication mode OFF");
|
||||
am.setMode(sPreviousAudioMode);
|
||||
sPreviousAudioMode = AudioManager.MODE_INVALID;
|
||||
am.stopBluetoothSco();
|
||||
am.setBluetoothScoOn(false);
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
Log.e(LOGTAG, "could not set communication mode", e);
|
||||
}
|
||||
|
||||
am.setSpeakerphoneOn(!on);
|
||||
}
|
||||
|
||||
private static String getLanguageTag(final Locale locale) {
|
||||
final StringBuilder out = new StringBuilder(locale.getLanguage());
|
||||
final String country = locale.getCountry();
|
||||
|
Loading…
Reference in New Issue
Block a user