use of android.bluetooth.BluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceProfilesSettings method refreshProfilePreference.
private void refreshProfilePreference(CheckBox profilePref, LocalBluetoothProfile profile) {
BluetoothDevice device = mCachedDevice.getDevice();
// Gray out checkbox while connecting and disconnecting.
profilePref.setEnabled(!mCachedDevice.isBusy());
if (profile instanceof MapProfile) {
profilePref.setChecked(mCachedDevice.getMessagePermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PbapServerProfile) {
profilePref.setChecked(mCachedDevice.getPhonebookPermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PanProfile) {
profilePref.setChecked(profile.getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED);
} else {
profilePref.setChecked(profile.isPreferred(device));
}
}
use of android.bluetooth.BluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DockService method parseIntent.
private Message parseIntent(Intent intent) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, -1234);
if (DEBUG) {
Log.d(TAG, "Action: " + intent.getAction() + " State:" + state + " Device: " + (device == null ? "null" : device.getAliasName()));
}
int msgType;
switch(state) {
case Intent.EXTRA_DOCK_STATE_UNDOCKED:
msgType = MSG_TYPE_UNDOCKED_TEMPORARY;
break;
case Intent.EXTRA_DOCK_STATE_DESK:
case Intent.EXTRA_DOCK_STATE_HE_DESK:
case Intent.EXTRA_DOCK_STATE_CAR:
if (device == null) {
Log.w(TAG, "device is null");
return null;
}
/// Fall Through ///
case Intent.EXTRA_DOCK_STATE_LE_DESK:
if (DockEventReceiver.ACTION_DOCK_SHOW_UI.equals(intent.getAction())) {
if (device == null) {
Log.w(TAG, "device is null");
return null;
}
msgType = MSG_TYPE_SHOW_UI;
} else {
msgType = MSG_TYPE_DOCKED;
}
break;
default:
return null;
}
return mServiceHandler.obtainMessage(msgType, state, 0, device);
}
use of android.bluetooth.BluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DockService method processMessage.
// This method gets messages from both onStartCommand and mServiceHandler/mServiceLooper
private synchronized void processMessage(Message msg) {
int msgType = msg.what;
final int state = msg.arg1;
final int startId = msg.arg2;
BluetoothDevice device = null;
if (msg.obj != null) {
device = (BluetoothDevice) msg.obj;
}
if (DEBUG)
Log.d(TAG, "processMessage: " + msgType + " state: " + state + " device = " + (device == null ? "null" : device.toString()));
boolean deferFinishCall = false;
switch(msgType) {
case MSG_TYPE_SHOW_UI:
if (device != null) {
createDialog(device, state, startId);
}
break;
case MSG_TYPE_DOCKED:
deferFinishCall = msgTypeDocked(device, state, startId);
break;
case MSG_TYPE_UNDOCKED_PERMANENT:
deferFinishCall = msgTypeUndockedPermanent(device, startId);
break;
case MSG_TYPE_UNDOCKED_TEMPORARY:
msgTypeUndockedTemporary(device, state, startId);
break;
case MSG_TYPE_DISABLE_BT:
deferFinishCall = msgTypeDisableBluetooth(startId);
break;
}
if (mDialog == null && mPendingDevice == null && msgType != MSG_TYPE_UNDOCKED_TEMPORARY && !deferFinishCall) {
// NOTE: We MUST not call stopSelf() directly, since we need to
// make sure the wake lock acquired by the Receiver is released.
DockEventReceiver.finishStartingService(this, startId);
}
}
use of android.bluetooth.BluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceProfilesSettings method onProfileClicked.
private void onProfileClicked(LocalBluetoothProfile profile, CheckBox profilePref) {
BluetoothDevice device = mCachedDevice.getDevice();
if (!profilePref.isChecked()) {
// Recheck it, until the dialog is done.
profilePref.setChecked(true);
askDisconnect(mManager.getForegroundActivity(), profile);
} else {
if (profile instanceof MapProfile) {
mCachedDevice.setMessagePermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
}
if (profile instanceof PbapServerProfile) {
mCachedDevice.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
refreshProfilePreference(profilePref, profile);
return;
}
if (profile.isPreferred(device)) {
// profile is preferred but not connected: disable auto-connect
if (profile instanceof PanProfile) {
mCachedDevice.connectProfile(profile);
} else {
profile.setPreferred(device, false);
}
} else {
profile.setPreferred(device, true);
mCachedDevice.connectProfile(profile);
}
refreshProfilePreference(profilePref, profile);
}
}
use of android.bluetooth.BluetoothDevice in project android_frameworks_base by ResurrectionRemix.
the class PbapClientProfile method connect.
public boolean connect(BluetoothDevice device) {
if (V) {
Log.d(TAG, "PBAPClientProfile got connect request");
}
if (mService == null) {
return false;
}
List<BluetoothDevice> srcs = getConnectedDevices();
if (srcs != null) {
for (BluetoothDevice src : srcs) {
if (src.equals(device)) {
// Connect to same device, Ignore it
Log.d(TAG, "Ignoring Connect");
return true;
}
}
for (BluetoothDevice src : srcs) {
mService.disconnect(device);
}
}
Log.d(TAG, "PBAPClientProfile attempting to connect to " + device.getAddress());
return mService.connect(device);
}
Aggregations