use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
the class Tethering method setBluetoothTethering.
private void setBluetoothTethering(final boolean enable, final ResultReceiver receiver) {
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter == null || !adapter.isEnabled()) {
Log.w(TAG, "Tried to enable bluetooth tethering with null or disabled adapter. null: " + (adapter == null));
sendTetherResult(receiver, ConnectivityManager.TETHER_ERROR_SERVICE_UNAVAIL);
return;
}
adapter.getProfileProxy(mContext, new ServiceListener() {
@Override
public void onServiceDisconnected(int profile) {
}
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
((BluetoothPan) proxy).setBluetoothTethering(enable);
// TODO: Enabling bluetooth tethering can fail asynchronously here.
// We should figure out a way to bubble up that failure instead of sending success.
int result = ((BluetoothPan) proxy).isTetheringOn() == enable ? ConnectivityManager.TETHER_ERROR_NO_ERROR : ConnectivityManager.TETHER_ERROR_MASTER_ERROR;
sendTetherResult(receiver, result);
if (enable && isTetherProvisioningRequired()) {
scheduleProvisioningRechecks(ConnectivityManager.TETHERING_BLUETOOTH);
}
adapter.closeProfileProxy(BluetoothProfile.PAN, proxy);
}
}, BluetoothProfile.PAN);
}
use of android.bluetooth.BluetoothAdapter in project AndroidChromium by JackyAndroid.
the class Utils method getBluetoothEnabledStatus.
public static int getBluetoothEnabledStatus() {
int statusResult = RESULT_INDETERMINATE;
if (isBluetoothPermissionGranted()) {
BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter();
statusResult = (bt != null && bt.isEnabled()) ? RESULT_SUCCESS : RESULT_FAILURE;
}
return statusResult;
}
use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by DirtyUnicorns.
the class ScanFilterTest method setUp.
@Override
protected void setUp() throws Exception {
byte[] scanRecord = new byte[] { // advertising flags
0x02, // advertising flags
0x01, // advertising flags
0x1a, // 16 bit service uuids
0x05, // 16 bit service uuids
0x02, // 16 bit service uuids
0x0b, // 16 bit service uuids
0x11, // 16 bit service uuids
0x0a, // 16 bit service uuids
0x11, // setName
0x04, // setName
0x09, // setName
0x50, // setName
0x65, // setName
0x64, // tx power level
0x02, // tx power level
0x0A, // tx power level
(byte) 0xec, // service data
0x05, // service data
0x16, // service data
0x0b, // service data
0x11, // service data
0x50, // service data
0x64, // manufacturer specific data
0x05, // manufacturer specific data
(byte) 0xff, // manufacturer specific data
(byte) 0xe0, // manufacturer specific data
0x00, // manufacturer specific data
0x02, // manufacturer specific data
0x15, // an unknown data type won't cause trouble
0x03, // an unknown data type won't cause trouble
0x50, // an unknown data type won't cause trouble
0x01, // an unknown data type won't cause trouble
0x02 };
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice device = adapter.getRemoteDevice(DEVICE_MAC);
mScanResult = new ScanResult(device, ScanRecord.parseFromBytes(scanRecord), -10, 1397545200000000L);
mFilterBuilder = new ScanFilter.Builder();
}
use of android.bluetooth.BluetoothAdapter in project android_frameworks_base by DirtyUnicorns.
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");
}
Aggregations