Java Code Examples for android.media.AudioManager#isBluetoothScoOn()
The following examples show how to use
android.media.AudioManager#isBluetoothScoOn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VoIPBaseService.java From Telegram with GNU General Public License v2.0 | 6 votes |
public int getCurrentAudioRoute(){ if(USE_CONNECTION_SERVICE){ if(systemCallConnection!=null && systemCallConnection.getCallAudioState()!=null){ switch(systemCallConnection.getCallAudioState().getRoute()){ case CallAudioState.ROUTE_BLUETOOTH: return AUDIO_ROUTE_BLUETOOTH; case CallAudioState.ROUTE_EARPIECE: case CallAudioState.ROUTE_WIRED_HEADSET: return AUDIO_ROUTE_EARPIECE; case CallAudioState.ROUTE_SPEAKER: return AUDIO_ROUTE_SPEAKER; } } return audioRouteToSet; } if(audioConfigured){ AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); if(am.isBluetoothScoOn()) return AUDIO_ROUTE_BLUETOOTH; else if(am.isSpeakerphoneOn()) return AUDIO_ROUTE_SPEAKER; else return AUDIO_ROUTE_EARPIECE; } return audioRouteToSet; }
Example 2
Source File: VoIPBaseService.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@SuppressLint("NewApi") @Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) { AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); if (isHeadsetPlugged || am.isSpeakerphoneOn() || (isBluetoothHeadsetConnected() && am.isBluetoothScoOn())) { return; } boolean newIsNear = event.values[0] < Math.min(event.sensor.getMaximumRange(), 3); if (newIsNear != isProximityNear) { if (BuildVars.LOGS_ENABLED) { FileLog.d("proximity " + newIsNear); } isProximityNear = newIsNear; try{ if(isProximityNear){ proximityWakelock.acquire(); }else{ proximityWakelock.release(1); // this is non-public API before L } }catch(Exception x){ FileLog.e(x); } } } }
Example 3
Source File: WebRtcCallService.java From bcm-android with GNU General Public License v3.0 | 6 votes |
private void handleWiredHeadsetChange(Intent intent) { ALog.d(TAG, "handleWiredHeadsetChange..."); CallState currentState = this.callState.get(); if (currentState == CallState.STATE_CONNECTED || currentState == CallState.STATE_DIALING || currentState == CallState.STATE_REMOTE_RINGING) { AudioManager audioManager = AppUtil.INSTANCE.getAudioManager(this); boolean present = intent.getBooleanExtra(EXTRA_AVAILABLE, false); if (present && audioManager.isSpeakerphoneOn()) { audioManager.setSpeakerphoneOn(false); audioManager.setBluetoothScoOn(false); } else if (!present && !audioManager.isSpeakerphoneOn() && !audioManager.isBluetoothScoOn() && localCameraState.isEnabled()) { audioManager.setSpeakerphoneOn(true); } if (recipient != null) { sendMessage(viewModelStateFor(callState.get()), recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled); } } }
Example 4
Source File: VoIPBaseService.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public int getCurrentAudioRoute(){ if(USE_CONNECTION_SERVICE){ if(systemCallConnection!=null && systemCallConnection.getCallAudioState()!=null){ switch(systemCallConnection.getCallAudioState().getRoute()){ case CallAudioState.ROUTE_BLUETOOTH: return AUDIO_ROUTE_BLUETOOTH; case CallAudioState.ROUTE_EARPIECE: case CallAudioState.ROUTE_WIRED_HEADSET: return AUDIO_ROUTE_EARPIECE; case CallAudioState.ROUTE_SPEAKER: return AUDIO_ROUTE_SPEAKER; } } return audioRouteToSet; } if(audioConfigured){ AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); if(am.isBluetoothScoOn()) return AUDIO_ROUTE_BLUETOOTH; else if(am.isSpeakerphoneOn()) return AUDIO_ROUTE_SPEAKER; else return AUDIO_ROUTE_EARPIECE; } return audioRouteToSet; }
Example 5
Source File: SignalAudioManager.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public void stop(boolean playDisconnected) { AudioManager audioManager = AppUtil.INSTANCE.getAudioManager(context); incomingRinger.stop(); outgoingRinger.stop(); if (playDisconnected) { soundPool.play(disconnectedSoundId, 1.0f, 1.0f, 0, 0, 1.0f); } if (audioManager.isBluetoothScoOn()) { audioManager.setBluetoothScoOn(false); audioManager.stopBluetoothSco(); } audioManager.setSpeakerphoneOn(false); audioManager.setMicrophoneMute(false); audioManager.setMode(AudioManager.MODE_NORMAL); audioManager.abandonAudioFocus(null); }
Example 6
Source File: VoIPBaseService.java From Telegram with GNU General Public License v2.0 | 6 votes |
@SuppressLint("NewApi") @Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) { AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); if (isHeadsetPlugged || am.isSpeakerphoneOn() || (isBluetoothHeadsetConnected() && am.isBluetoothScoOn())) { return; } boolean newIsNear = event.values[0] < Math.min(event.sensor.getMaximumRange(), 3); if (newIsNear != isProximityNear) { if (BuildVars.LOGS_ENABLED) { FileLog.d("proximity " + newIsNear); } isProximityNear = newIsNear; try{ if(isProximityNear){ proximityWakelock.acquire(); }else{ proximityWakelock.release(1); // this is non-public API before L } }catch(Exception x){ FileLog.e(x); } } } }
Example 7
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public int getCurrentAudioRoute(){ if(USE_CONNECTION_SERVICE){ if(systemCallConnection!=null && systemCallConnection.getCallAudioState()!=null){ switch(systemCallConnection.getCallAudioState().getRoute()){ case CallAudioState.ROUTE_BLUETOOTH: return AUDIO_ROUTE_BLUETOOTH; case CallAudioState.ROUTE_EARPIECE: case CallAudioState.ROUTE_WIRED_HEADSET: return AUDIO_ROUTE_EARPIECE; case CallAudioState.ROUTE_SPEAKER: return AUDIO_ROUTE_SPEAKER; } } return audioRouteToSet; } if(audioConfigured){ AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); if(am.isBluetoothScoOn()) return AUDIO_ROUTE_BLUETOOTH; else if(am.isSpeakerphoneOn()) return AUDIO_ROUTE_SPEAKER; else return AUDIO_ROUTE_EARPIECE; } return audioRouteToSet; }
Example 8
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@SuppressLint("NewApi") @Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) { AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); if (isHeadsetPlugged || am.isSpeakerphoneOn() || (isBluetoothHeadsetConnected() && am.isBluetoothScoOn())) { return; } boolean newIsNear = event.values[0] < Math.min(event.sensor.getMaximumRange(), 3); if (newIsNear != isProximityNear) { if (BuildVars.LOGS_ENABLED) { FileLog.d("proximity " + newIsNear); } isProximityNear = newIsNear; try{ if(isProximityNear){ proximityWakelock.acquire(); }else{ proximityWakelock.release(1); // this is non-public API before L } }catch(Exception x){ FileLog.e(x); } } } }
Example 9
Source File: WebRtcCallService.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void handleWiredHeadsetChange(Intent intent) { Log.i(TAG, "handleWiredHeadsetChange..."); if ((activePeer != null) && (activePeer.getState() == CallState.CONNECTED || activePeer.getState() == CallState.DIALING || activePeer.getState() == CallState.RECEIVED_BUSY || activePeer.getState() == CallState.REMOTE_RINGING)) { AudioManager audioManager = ServiceUtil.getAudioManager(this); boolean present = intent.getBooleanExtra(EXTRA_AVAILABLE, false); if (present && audioManager.isSpeakerphoneOn()) { audioManager.setSpeakerphoneOn(false); audioManager.setBluetoothScoOn(false); } else if (!present && !audioManager.isSpeakerphoneOn() && !audioManager.isBluetoothScoOn() && localCameraState.isEnabled()) { audioManager.setSpeakerphoneOn(true); } sendMessage(viewModelStateFor(activePeer), activePeer, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled, isRemoteVideoOffer); } }
Example 10
Source File: AssistantService.java From AssistantBySDK with Apache License 2.0 | 6 votes |
@Override public void execute(AudioManager audioManager) { if (voiceMediator.isBlueToothHeadSet()) { if (!voiceMediator.isSuportA2DP()) { if (audioManager.getMode() != AudioManager.MODE_NORMAL) { Log.e(TAG, "playInChannel>>setMode(AudioManager.MODE_NORMAL)"); audioManager.setMode(AudioManager.MODE_NORMAL); } if (audioManager.isBluetoothScoOn()) { audioManager.setBluetoothScoOn(false); audioManager.stopBluetoothSco(); } } else { if (!audioManager.isBluetoothA2dpOn()) { Log.e(TAG, "playInChannel>>setBluetoothA2dpOn(true)"); audioManager.setBluetoothA2dpOn(true); } } } }
Example 11
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public int getCurrentAudioRoute(){ if(USE_CONNECTION_SERVICE){ if(systemCallConnection!=null && systemCallConnection.getCallAudioState()!=null){ switch(systemCallConnection.getCallAudioState().getRoute()){ case CallAudioState.ROUTE_BLUETOOTH: return AUDIO_ROUTE_BLUETOOTH; case CallAudioState.ROUTE_EARPIECE: case CallAudioState.ROUTE_WIRED_HEADSET: return AUDIO_ROUTE_EARPIECE; case CallAudioState.ROUTE_SPEAKER: return AUDIO_ROUTE_SPEAKER; } } return audioRouteToSet; } if(audioConfigured){ AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); if(am.isBluetoothScoOn()) return AUDIO_ROUTE_BLUETOOTH; else if(am.isSpeakerphoneOn()) return AUDIO_ROUTE_SPEAKER; else return AUDIO_ROUTE_EARPIECE; } return audioRouteToSet; }
Example 12
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@SuppressLint("NewApi") @Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) { AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); if (isHeadsetPlugged || am.isSpeakerphoneOn() || (isBluetoothHeadsetConnected() && am.isBluetoothScoOn())) { return; } boolean newIsNear = event.values[0] < Math.min(event.sensor.getMaximumRange(), 3); if (newIsNear != isProximityNear) { if (BuildVars.LOGS_ENABLED) { FileLog.d("proximity " + newIsNear); } isProximityNear = newIsNear; try{ if(isProximityNear){ proximityWakelock.acquire(); }else{ proximityWakelock.release(1); // this is non-public API before L } }catch(Exception x){ FileLog.e(x); } } } }
Example 13
Source File: AudioManagerUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 检查通信是否使用蓝牙 SCO * @return {@code true} yes, {@code false} no */ public static boolean isBluetoothScoOn() { AudioManager audioManager = AppUtils.getAudioManager(); if (audioManager != null) { try { return audioManager.isBluetoothScoOn(); } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "isBluetoothScoOn"); } } return false; }
Example 14
Source File: VoIPBaseService.java From Telegram with GNU General Public License v2.0 | 5 votes |
public boolean isSpeakerphoneOn(){ if(USE_CONNECTION_SERVICE && systemCallConnection!=null && systemCallConnection.getCallAudioState()!=null){ int route=systemCallConnection.getCallAudioState().getRoute(); return hasEarpiece() ? route==CallAudioState.ROUTE_SPEAKER : route==CallAudioState.ROUTE_BLUETOOTH; }else if(audioConfigured && !USE_CONNECTION_SERVICE){ AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); return hasEarpiece() ? am.isSpeakerphoneOn() : am.isBluetoothScoOn(); } return speakerphoneStateToSet; }
Example 15
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public boolean isSpeakerphoneOn(){ if(USE_CONNECTION_SERVICE && systemCallConnection!=null && systemCallConnection.getCallAudioState()!=null){ int route=systemCallConnection.getCallAudioState().getRoute(); return hasEarpiece() ? route==CallAudioState.ROUTE_SPEAKER : route==CallAudioState.ROUTE_BLUETOOTH; }else if(audioConfigured && !USE_CONNECTION_SERVICE){ AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); return hasEarpiece() ? am.isSpeakerphoneOn() : am.isBluetoothScoOn(); } return speakerphoneStateToSet; }
Example 16
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public boolean isSpeakerphoneOn(){ if(USE_CONNECTION_SERVICE && systemCallConnection!=null && systemCallConnection.getCallAudioState()!=null){ int route=systemCallConnection.getCallAudioState().getRoute(); return hasEarpiece() ? route==CallAudioState.ROUTE_SPEAKER : route==CallAudioState.ROUTE_BLUETOOTH; }else if(audioConfigured && !USE_CONNECTION_SERVICE){ AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE); return hasEarpiece() ? am.isSpeakerphoneOn() : am.isBluetoothScoOn(); } return speakerphoneStateToSet; }
Example 17
Source File: SignalAudioManager.java From bcm-android with GNU General Public License v3.0 | 5 votes |
public void startIncomingRinger() { AudioManager audioManager = AppUtil.INSTANCE.getAudioManager(context); boolean speaker = !audioManager.isWiredHeadsetOn() && !audioManager.isBluetoothScoOn(); audioManager.setMode(AudioManager.MODE_RINGTONE); audioManager.setMicrophoneMute(false); audioManager.setSpeakerphoneOn(speaker); incomingRinger.start(); }
Example 18
Source File: SignalAudioManager.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public void startIncomingRinger(@Nullable Uri ringtoneUri, boolean vibrate) { AudioManager audioManager = ServiceUtil.getAudioManager(context); boolean speaker = !audioManager.isWiredHeadsetOn() && !audioManager.isBluetoothScoOn(); audioManager.setMode(AudioManager.MODE_RINGTONE); audioManager.setMicrophoneMute(false); audioManager.setSpeakerphoneOn(speaker); incomingRinger.start(ringtoneUri, vibrate); }
Example 19
Source File: WebRtcCallService.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private LockManager.PhoneState getInCallPhoneState() { AudioManager audioManager = ServiceUtil.getAudioManager(this); if (audioManager.isSpeakerphoneOn() || audioManager.isBluetoothScoOn() || audioManager.isWiredHeadsetOn()) { return LockManager.PhoneState.IN_HANDS_FREE_CALL; } else { return LockManager.PhoneState.IN_CALL; } }
Example 20
Source File: WebRtcCallService.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private void handleSetEnableVideo(Intent intent) { boolean enable = intent.getBooleanExtra(EXTRA_ENABLE, false); AudioManager audioManager = ServiceUtil.getAudioManager(this); if (activePeer == null) { Log.w(TAG, "handleSetEnableVideo(): Ignoring for inactive call."); return; } Log.i(TAG, "handleSetEnableVideo(): call_id: " + activePeer.getCallId()); if (activePeer.getState() != CallState.CONNECTED) { enableVideoOnCreate = enable; if (enableVideoOnCreate && !audioManager.isSpeakerphoneOn() && !audioManager.isBluetoothScoOn() && !audioManager.isWiredHeadsetOn()) { audioManager.setSpeakerphoneOn(true); } return; } try { callManager.setVideoEnable(enable); } catch (CallException e) { callFailure("setVideoEnable() failed: ", e); return; } localCameraState = camera.getCameraState(); if (localCameraState.isEnabled()) { lockManager.updatePhoneState(LockManager.PhoneState.IN_VIDEO); } else { lockManager.updatePhoneState(getInCallPhoneState()); } if (localCameraState.isEnabled() && !audioManager.isSpeakerphoneOn() && !audioManager.isBluetoothScoOn() && !audioManager.isWiredHeadsetOn()) { audioManager.setSpeakerphoneOn(true); } sendMessage(viewModelStateFor(activePeer), activePeer, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled, isRemoteVideoOffer); }