@Test public void getMode_default() { assertThat(audioManager.getMode()).isEqualTo(AudioManager.MODE_NORMAL); }
@Test public void setMode_shouldSetAudioMode() { audioManager.setMode(AudioManager.MODE_RINGTONE); assertThat(audioManager.getMode()).isEqualTo(AudioManager.MODE_RINGTONE); }
private boolean isCommunicationModeEnabled() { return (audioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION); }
/**messagePop调用*/ public int getAudioMode(Context ctx) { AudioManager audioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE); return audioManager.getMode(); }
private boolean isInCall() { AudioManager manager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); boolean inCall = (manager.getMode() == AudioManager.MODE_IN_CALL || manager.getMode() == AudioManager.MODE_IN_COMMUNICATION); mLogger.debug("Device is in a call: " + inCall); return inCall; } }
@SuppressWarnings("ConstantConditions") private static boolean isOngoingCall() { final AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE); try { return (manager.getMode() == AudioManager.MODE_IN_CALL); } catch (NullPointerException e) { return false; } }
public static boolean isOngoingCall() { try { AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE); return (manager.getMode() == AudioManager.MODE_IN_CALL); // possibly should have MODE_IN_COMMUNICATION as well } catch (Exception e) { return false; } }
public static boolean isOngoingCall() { try { AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE); return (manager.getMode() == AudioManager.MODE_IN_CALL); // possibly should have MODE_IN_COMMUNICATION as well } catch (Exception e) { return false; } }
public static boolean isOngoingCall() { try { AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE); return (manager.getMode() == AudioManager.MODE_IN_CALL); // possibly should have MODE_IN_COMMUNICATION as well } catch (Exception e) { return false; } }
@SuppressWarnings("ConstantConditions") private static boolean isOngoingCall() { final AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE); try { return (manager.getMode() == AudioManager.MODE_IN_CALL); } catch (NullPointerException e) { return false; } }
private void initMediaPlayer() { // Make the media play through earpiece instead of through speaker(default) AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); prevMode = am.getMode(); am.setMode(AudioManager.MODE_IN_COMMUNICATION); am.setSpeakerphoneOn(false);
/** * Back up the current audio config. */ private void backupAudioConfig() { if (null == mAudioMode) { AudioManager audioManager = getAudioManager(); mAudioMode = audioManager.getMode(); mIsSpeakerphoneOn = audioManager.isSpeakerphoneOn(); } }
private int getAudioManagerMode() { try { return ((AudioManager) getSystemService(Context.AUDIO_SERVICE)).getMode(); } catch (NullPointerException e) { log.e(e, "NotificationService isRinging Exception: %s", e.toString()); return AudioManager.MODE_INVALID; } }
private boolean init() { Logging.d(TAG, "init" + WebRtcAudioUtils.getThreadInfo()); if (initialized) { return true; } Logging.d(TAG, "audio mode is: " + AUDIO_MODES[audioManager.getMode()]); initialized = true; volumeLogger.start(); return true; }
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // get original mode int originalMode = audioManager.getMode(); audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); // change mute boolean state = !audioManager.isMicrophoneMute(); audioManager.setMicrophoneMute(state); // set mode back audioManager.setMode(originalMode);
json.put("mode", manager.getMode()); json.put("ringermode", manager.getRingerMode());
public void run() { final int mode = audioManager.getMode(); if (mode == AudioManager.MODE_RINGTONE) { Logging.d(TAG, "STREAM_RING stream volume: " + audioManager.getStreamVolume(AudioManager.STREAM_RING) + " (max=" + maxRingVolume + ")"); } else if (mode == AudioManager.MODE_IN_COMMUNICATION) { Logging.d(TAG, "VOICE_CALL stream volume: " + audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL) + " (max=" + maxVoiceCallVolume + ")"); } } }
int oldAudioMode = audioManager.getMode(); audioManager.setMode(AudioManager.MODE_IN_CALL); audioManager.setMicrophoneMute(true);
if (audioManager.getMode() != audioMode) { audioManager.setMode(audioMode);
/** * Restore the audio config. */ private void restoreAudioConfig() { // ensure that something has been saved if ((null != mAudioMode) && (null != mIsSpeakerphoneOn)) { Log.d(LOG_TAG, "## restoreAudioConfig() starts"); AudioManager audioManager = getAudioManager(); if (mAudioMode != audioManager.getMode()) { Log.d(LOG_TAG, "## restoreAudioConfig() : restore audio mode " + mAudioMode); audioManager.setMode(mAudioMode); } if (mIsSpeakerphoneOn != audioManager.isSpeakerphoneOn()) { Log.d(LOG_TAG, "## restoreAudioConfig() : restore speaker " + mIsSpeakerphoneOn); audioManager.setSpeakerphoneOn(mIsSpeakerphoneOn); } // stop the bluetooth if (audioManager.isBluetoothScoOn()) { Log.d(LOG_TAG, "## restoreAudioConfig() : ends the bluetooth calls"); audioManager.stopBluetoothSco(); audioManager.setBluetoothScoOn(false); } mAudioMode = null; mIsSpeakerphoneOn = null; Log.d(LOG_TAG, "## restoreAudioConfig() done"); } }