use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ParanoidAndroid.
the class ExternalSharedPermsDiffKeyTest method testRunBluetoothAndFineLocation.
/** The use of location manager and bluetooth below are simply to simulate an app that
* tries to use them, so we can verify whether permissions are granted and accessible.
* */
public void testRunBluetoothAndFineLocation() {
LocationManager locationManager = (LocationManager) getInstrumentation().getContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
public void onLocationChanged(Location location) {
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
});
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if ((mBluetoothAdapter != null) && (!mBluetoothAdapter.isEnabled())) {
mBluetoothAdapter.getName();
}
fail("this app was signed by a different cert and should crash/fail to run by now");
}
use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ParanoidAndroid.
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);
}
use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ParanoidAndroid.
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);
}
}
}
use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ResurrectionRemix.
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);
}
use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ResurrectionRemix.
the class ExternalSharedPermsTest method testRunLocationAndBluetooth.
/** The use of location manager and bluetooth below are simply to simulate an app that
* tries to use them, so we can verify whether permissions are granted and accessible.
* */
public void testRunLocationAndBluetooth() {
LocationManager locationManager = (LocationManager) getInstrumentation().getContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
public void onLocationChanged(Location location) {
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
});
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if ((mBluetoothAdapter != null) && (!mBluetoothAdapter.isEnabled())) {
mBluetoothAdapter.getName();
}
}
Aggregations