Search in sources :

Example 1 with AudioManager

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());
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) InputMethodManager(android.view.inputmethod.InputMethodManager) ActivityManager(android.app.ActivityManager) WindowManager(android.view.WindowManager) PowerManager(android.os.PowerManager) AudioManager(android.media.AudioManager) StateManager(proton.inject.state.StateManager) TelephonyManager(android.telephony.TelephonyManager) Context(android.content.Context) LocationManager(android.location.LocationManager) ApplicationProvider(proton.inject.provider.ApplicationProvider) NotificationManager(android.app.NotificationManager) HandlerProvider(proton.inject.provider.HandlerProvider) RetainStateListener(proton.inject.state.RetainStateListener) SensorManager(android.hardware.SensorManager) AlarmManager(android.app.AlarmManager) Vibrator(android.os.Vibrator) KeyguardManager(android.app.KeyguardManager) ObserverRegister(proton.inject.observer.ObserverRegister)

Example 2 with AudioManager

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);
        }
    }
}
Also used : SignalAudioManager(org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager) AudioManager(android.media.AudioManager)

Example 3 with AudioManager

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;
        }
    }
}
Also used : AudioManager(android.media.AudioManager)

Example 4 with AudioManager

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);
    }
}
Also used : AudioManager(android.media.AudioManager) IOException(java.io.IOException)

Example 5 with AudioManager

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);
}
Also used : AudioManager(android.media.AudioManager)

Aggregations

AudioManager (android.media.AudioManager)313 MediaPlayer (android.media.MediaPlayer)62 AudioEffect (android.media.audiofx.AudioEffect)42 LargeTest (android.test.suitebuilder.annotation.LargeTest)42 EnergyProbe (com.android.mediaframeworktest.functional.EnergyProbe)24 Context (android.content.Context)23 IOException (java.io.IOException)23 SuppressLint (android.annotation.SuppressLint)17 Intent (android.content.Intent)14 Handler (android.os.Handler)12 SharedPreferences (android.content.SharedPreferences)10 View (android.view.View)10 Uri (android.net.Uri)9 TargetApi (android.annotation.TargetApi)8 PowerManager (android.os.PowerManager)8 UserManager (android.os.UserManager)8 SurfaceHolder (android.view.SurfaceHolder)8 NotificationManager (android.app.NotificationManager)7 Vibrator (android.os.Vibrator)7 Condition (android.service.notification.Condition)7