Search in sources :

Example 76 with BluetoothAdapter

use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ResurrectionRemix.

the class ScoAudioTest method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    mTts.shutdown();
    unregisterReceiver(mReceiver);
    if (mBluetoothHeadset != null) {
        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
        if (btAdapter != null) {
            btAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
        }
    }
}
Also used : BluetoothAdapter(android.bluetooth.BluetoothAdapter)

Example 77 with BluetoothAdapter

use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ResurrectionRemix.

the class AudioService method onSystemReady.

public void onSystemReady() {
    mSystemReady = true;
    sendMsg(mAudioHandler, MSG_LOAD_SOUND_EFFECTS, SENDMSG_QUEUE, 0, 0, null, 0);
    mScoConnectionState = AudioManager.SCO_AUDIO_STATE_ERROR;
    resetBluetoothSco();
    getBluetoothHeadset();
    //FIXME: this is to maintain compatibility with deprecated intent
    // AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED. Remove when appropriate.
    Intent newIntent = new Intent(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED);
    newIntent.putExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, AudioManager.SCO_AUDIO_STATE_DISCONNECTED);
    sendStickyBroadcastToAll(newIntent);
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    if (adapter != null) {
        adapter.getProfileProxy(mContext, mBluetoothProfileServiceListener, BluetoothProfile.A2DP);
    }
    mHdmiManager = (HdmiControlManager) mContext.getSystemService(Context.HDMI_CONTROL_SERVICE);
    if (mHdmiManager != null) {
        synchronized (mHdmiManager) {
            mHdmiTvClient = mHdmiManager.getTvClient();
            if (mHdmiTvClient != null) {
                mFixedVolumeDevices &= ~AudioSystem.DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER;
            }
            mHdmiPlaybackClient = mHdmiManager.getPlaybackClient();
            mHdmiCecSink = false;
        }
    }
    mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    sendMsg(mAudioHandler, MSG_CONFIGURE_SAFE_MEDIA_VOLUME_FORCED, SENDMSG_REPLACE, 0, 0, TAG, SAFE_VOLUME_CONFIGURE_TIMEOUT_MS);
    StreamOverride.init(mContext);
    mControllerService.init();
    onIndicateSystemReady();
}
Also used : Intent(android.content.Intent) BluetoothAdapter(android.bluetooth.BluetoothAdapter)

Example 78 with BluetoothAdapter

use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ResurrectionRemix.

the class AudioService method getBluetoothHeadset.

private boolean getBluetoothHeadset() {
    boolean result = false;
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    if (adapter != null) {
        result = adapter.getProfileProxy(mContext, mBluetoothProfileServiceListener, BluetoothProfile.HEADSET);
    }
    // If we could not get a bluetooth headset proxy, send a failure message
    // without delay to reset the SCO audio state and clear SCO clients.
    // If we could get a proxy, send a delayed failure message that will reset our state
    // in case we don't receive onServiceConnected().
    sendMsg(mAudioHandler, MSG_BT_HEADSET_CNCT_FAILED, SENDMSG_REPLACE, 0, 0, null, result ? BT_HEADSET_CNCT_TIMEOUT_MS : 0);
    return result;
}
Also used : BluetoothAdapter(android.bluetooth.BluetoothAdapter)

Example 79 with BluetoothAdapter

use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by DirtyUnicorns.

the class ScoAudioTest method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    mTts.shutdown();
    unregisterReceiver(mReceiver);
    if (mBluetoothHeadset != null) {
        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
        if (btAdapter != null) {
            btAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
        }
    }
}
Also used : BluetoothAdapter(android.bluetooth.BluetoothAdapter)

Example 80 with BluetoothAdapter

use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by DirtyUnicorns.

the class ScoAudioTest method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.scoaudiotest);
    mScoStateTxt = (TextView) findViewById(R.id.scoStateTxt);
    mVdStateTxt = (TextView) findViewById(R.id.vdStateTxt);
    IntentFilter intentFilter = new IntentFilter(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
    intentFilter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED);
    intentFilter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);
    registerReceiver(mReceiver, intentFilter);
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mAudioManager2 = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
    mHandler = new Handler();
    mMediaControllers[0] = new SimplePlayerController(this, R.id.playPause1, R.id.stop1, R.raw.sine440_mo_16b_16k, AudioManager.STREAM_BLUETOOTH_SCO);
    TextView name = (TextView) findViewById(R.id.playPause1Text);
    name.setText("VOICE_CALL stream");
    mScoButton = (ToggleButton) findViewById(R.id.ForceScoButton);
    mScoButton.setOnCheckedChangeListener(mForceScoChanged);
    mForceScoOn = false;
    mScoButton.setChecked(mForceScoOn);
    mVoiceDialerButton = (ToggleButton) findViewById(R.id.VoiceDialerButton);
    mVoiceDialerButton.setOnCheckedChangeListener(mVoiceDialerChanged);
    mVoiceDialerOn = false;
    mVoiceDialerButton.setChecked(mVoiceDialerOn);
    mMediaControllers[1] = new SimpleRecordController(this, R.id.recStop1, 0, "Sco_record_");
    mTtsInited = false;
    mTts = new TextToSpeech(this, new TtsInitListener());
    mTtsParams = new HashMap<String, String>();
    mTtsParams.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_BLUETOOTH_SCO));
    mTtsParams.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, UTTERANCE);
    mSpeakText = (EditText) findViewById(R.id.speakTextEdit);
    mSpeakText.setOnKeyListener(mSpeakKeyListener);
    mSpeakText.setText("sco audio test sentence");
    mTtsToFileButton = (ToggleButton) findViewById(R.id.TtsToFileButton);
    mTtsToFileButton.setOnCheckedChangeListener(mTtsToFileChanged);
    mTtsToFile = true;
    mTtsToFileButton.setChecked(mTtsToFile);
    mModeSpinner = (Spinner) findViewById(R.id.modeSpinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mModeStrings);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mModeSpinner.setAdapter(adapter);
    mModeSpinner.setOnItemSelectedListener(mModeChanged);
    mCurrentMode = mAudioManager.getMode();
    mModeSpinner.setSelection(mCurrentMode);
    mBluetoothHeadsetDevice = null;
    BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
    if (btAdapter != null) {
        btAdapter.getProfileProxy(this, mBluetoothProfileServiceListener, BluetoothProfile.HEADSET);
    }
    sVoiceCommandIntent = new Intent(Intent.ACTION_VOICE_COMMAND);
    sVoiceCommandIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
Also used : IntentFilter(android.content.IntentFilter) Handler(android.os.Handler) Intent(android.content.Intent) TextToSpeech(android.speech.tts.TextToSpeech) TextView(android.widget.TextView) BluetoothAdapter(android.bluetooth.BluetoothAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

BluetoothAdapter (android.bluetooth.BluetoothAdapter)87 Intent (android.content.Intent)15 Location (android.location.Location)12 LocationListener (android.location.LocationListener)12 LocationManager (android.location.LocationManager)12 Bundle (android.os.Bundle)12 BluetoothDevice (android.bluetooth.BluetoothDevice)11 IntentFilter (android.content.IntentFilter)7 Handler (android.os.Handler)6 TextToSpeech (android.speech.tts.TextToSpeech)6 ArrayAdapter (android.widget.ArrayAdapter)6 TextView (android.widget.TextView)6 BluetoothActivityEnergyInfo (android.bluetooth.BluetoothActivityEnergyInfo)5 BluetoothProfile (android.bluetooth.BluetoothProfile)5 ServiceListener (android.bluetooth.BluetoothProfile.ServiceListener)5 ScanFilter (android.bluetooth.le.ScanFilter)5 WifiActivityEnergyInfo (android.net.wifi.WifiActivityEnergyInfo)5 RemoteException (android.os.RemoteException)5 SynchronousResultReceiver (android.os.SynchronousResultReceiver)5 ModemActivityInfo (android.telephony.ModemActivityInfo)5