use of android.media.AudioManager in project AndroidTraining by mixi-inc.
the class DefaultModule method configure.
@SuppressWarnings("unchecked")
protected void configure() {
bind(Application.class).toProvider(ApplicationProvider.class).in(ApplicationScoped.class);
bind(Context.class).toProvider(ContextProvider.class);
bind(Handler.class).toProvider(HandlerProvider.class).in(ApplicationScoped.class);
bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
bind(AudioManager.class).toProvider(new SystemServiceProvider<AudioManager>(Context.AUDIO_SERVICE));
bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
bind(mAccountManagerClass).toProvider(AccountManagerProvider.class);
bind(ObserverManager.class);
bindProviderListener(new ObserverRegister());
bind(StateManager.class).in(ApplicationScoped.class);
bind(StateEventObserver.class);
bindFieldListener(RetainState.class, new RetainStateListener());
}
use of android.media.AudioManager in project Signal-Android by WhisperSystems.
the class WebRtcCallService method handleWiredHeadsetChange.
private void handleWiredHeadsetChange(Intent intent) {
Log.w(TAG, "handleWiredHeadsetChange...");
if (callState == CallState.STATE_CONNECTED || callState == CallState.STATE_DIALING || callState == CallState.STATE_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() && localVideoEnabled) {
audioManager.setSpeakerphoneOn(true);
}
if (recipient != null) {
sendMessage(viewModelStateFor(callState), recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
}
}
}
use of android.media.AudioManager in project Signal-Android by WhisperSystems.
the class BluetoothStateManager method setWantsConnection.
public void setWantsConnection(boolean enabled) {
synchronized (LOCK) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
this.wantsConnection = enabled;
if (wantsConnection && isBluetoothAvailable() && scoConnection == ScoConnection.DISCONNECTED) {
audioManager.startBluetoothSco();
scoConnection = ScoConnection.IN_PROGRESS;
} else if (!wantsConnection && scoConnection == ScoConnection.CONNECTED) {
audioManager.stopBluetoothSco();
audioManager.setBluetoothScoOn(false);
scoConnection = ScoConnection.DISCONNECTED;
} else if (!wantsConnection && scoConnection == ScoConnection.IN_PROGRESS) {
audioManager.stopBluetoothSco();
scoConnection = ScoConnection.DISCONNECTED;
}
}
}
use of android.media.AudioManager in project Signal-Android by WhisperSystems.
the class IncomingRinger method start.
public void start(boolean speakerphone) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
if (player != null)
player.release();
player = createPlayer();
int ringerMode = audioManager.getRingerMode();
if (shouldVibrate(context, player, ringerMode)) {
Log.i(TAG, "Starting vibration");
vibrator.vibrate(VIBRATE_PATTERN, 1);
}
if (player != null && ringerMode == AudioManager.RINGER_MODE_NORMAL) {
try {
if (!player.isPlaying()) {
player.prepare();
player.start();
Log.w(TAG, "Playing ringtone now...");
} else {
Log.w(TAG, "Ringtone is already playing, declining to restart.");
}
} catch (IllegalStateException | IOException e) {
Log.w(TAG, e);
player = null;
}
} else {
Log.w(TAG, "Not ringing, mode: " + ringerMode);
}
if (speakerphone) {
audioManager.setSpeakerphoneOn(true);
}
}
use of android.media.AudioManager in project Signal-Android by WhisperSystems.
the class SignalAudioManager method startOutgoingRinger.
public void startOutgoingRinger(OutgoingRinger.Type type) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
audioManager.setMicrophoneMute(false);
if (type == OutgoingRinger.Type.SONAR) {
audioManager.setSpeakerphoneOn(false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
} else {
audioManager.setMode(AudioManager.MODE_IN_CALL);
}
outgoingRinger.start(type);
}
Aggregations